Hi All,
I got the following code from the Borland Web site and I think I have seen it
or something like it here in the past. Anyway, this only works in Delphi 1.x,
does anyone have a Delphi 2.0 function that will do the same thing? Or, if
you know how to modify it, that would be helpful. Here is the function:
Function WinExecAndWait(Path : string; Visibility : word) : word;
var
InstanceID : THandle;
PathLen : integer;
begin
{ inplace conversion of a String to a PChar }
PathLen := Length(Path);
Move(Path[1],Path[0],PathLen);
Path[PathLen] := #0;
{ Try to run the application }
InstanceID := WinExec(@Path,Visibility);
if InstanceID < 32 then { a value less than 32 indicates an Exec error }
WinExecAndWait := InstanceID
else
begin
Repeat
Application.ProcessMessages;
until Application.Terminated or (GetModuleUsage(InstanceID) = 0);
WinExecAndWait := 32;
end;
end;
The Delphi 2 help says to use the CreateProcess instead of WinExec, but I
have not had much luck with it. I admit I haven't spent much time on it, but
don't want to waste a bunch of time on it and then find out there is a bug or
something I didn't know about.
Can someone offer some help here?
Steve
--- FreeMail 1.07b
(1:203/21)
---------------
* Origin: The Visual Programmer's Workshop - N.H., Ca (916)338-3230 *
|