Delphi Posted October 13, 2010 Share Posted October 13, 2010 (edited) In Xepg I offer to launch DVBViewer (if not running) prior to the import of XMLTV EPG. To test if the DVBViewer is ready I have successfully used the FindInROT from the DVBViewer spy. This causes problems with version 4.5 and can be reproduced by adding a TButton to the DVBVSpy and the following code: function DVBViewerIsRunning: boolean; begin Result := FindinROT(guidtostring(CLASS_DVBViewer)); end; function ExecuteFile(const FileName, Params, DefaultDir: string; ShowCmd: Integer): THandle; begin Result := ShellExecute(Application.MainForm.Handle, nil, PChar(FileName), PChar(Params), PChar(DefaultDir), ShowCmd); end; const // hardcoded for testing only DVBViewerFileName: TFileName = 'c:\programmer\DVBViewer\DVBViewer.exe'; function LaunchDVBViewer: boolean; var TimeOut: boolean; n: integer; begin Result := DVBViewerIsRunning; if Result Then Exit; try Result := ExecuteFile(DVBViewerFileName, '', '', SW_SHOW) > 32; except Result := False; Exit; end; n := 0; repeat Sleep(100); TimeOut := n > 10*40;// 40 seconds? Inc(n); until DVBViewerIsRunning or TimeOut; Result := not TimeOut; end; procedure Twork.Button1Click(Sender: TObject); begin if not LaunchDVBViewer then Button1.Caption := 'FAILED!'; end; This now allways results in a TimeOut, but the DVBViewer is actually launched AFTER the Timeout. I have tried to use QueryInterface and ShellExecuteEx, but with no luck. Well, I am not an expert in the flag settings of ShellExecuteEx. One weird thing is that users (and I) report back, that things work if the DVBViewer is upgraded on a system with a working Xepg. Originally I tried to launch DVBViewer using COM ( FDVBViewer.ConnectKind := ckRunningOrNew;). This didn't work since the imported EPG was not saved to disk in that case. Has this changed? Any suggestions are appriciated. Edited October 13, 2010 by Delphi Quote Link to comment
Delphi Posted October 15, 2010 Author Share Posted October 15, 2010 You developer guys are not very nice to me! The solution ofcourse is to insert Application.ProcessMessages in the testing loop. What a stupid bug. You could have told me that. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.