Jump to content

FindInROT/SlellExecute works different


Delphi

Recommended Posts

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 by Delphi
Link to comment

You developer guys are not very nice to me! :tongue::biggrin:

 

The solution ofcourse is to insert Application.ProcessMessages in the testing loop. :blush::blush::blush:

 

What a stupid bug. You could have told me that. ;)

 

:bye:

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...