
Advanced : Shell doesn't appear to be running asynchronously
In my previously experience Shell has normally always returned the process
id almost instantaneously.
However, recently I have come across two instances where it hasn't doesn't
this.
The first time was when calling an exe, which added data to a database. The
ProcID didn't return until the code had finished
executing, which was a pain because I wanted to be able to abort the
execution if it took over a specified period of time.
The second time was when shelling the DLL to show the printer control panel
I couldn't get the 'Printer' Dialog to display unless I put a message box in
the calling code. i.e.:
lRetVal = Shell(CommandLine, State)
If lRetVal Then
Sleep 200
'Need to display a msgbox to pick up the windows handle of the DLL
dialog
MsgBox "Install a Printer, then Close the dialog " & Chr(13) & "and
Compass will continue running... ", vbInformation + vbSystemModal
lRetVal = FindWindow("CabinetWClass" & vbNullString, ByVal
vbNullString)
I actually wanted to use the Proc ID and then OpenProcess along with
WaitForSingleObject, to see when the window had closed, but I couldn't get
it to work??!!
This leads me to believe that the Proc ID isn't returned until a specific
message has been given from the called application, this seems to happen
when
a form or message box is displayed. Does anyone know how to force the Proc
ID to return at the start of execution????
--
Regards,
Andrew Baker
http://www.*-*-*.com/