VB ShellingThe normal 16Bit code is as follows...
Dim instance As Integer
instance = Shell("pbrush", 1)
Do While GetModuleUsage(instance) <> 0
DoEvents
Loop
However, when calling a 32bit app, the GetModuleUsage(instance) always returns 0! Is there any solution, that you may know?
From: Peter Kowald
Organization: Automation & Process Control
Email: apc1@ozemail.com.au
So what you get is two apps running in separate address spaces. If you were starting a 16bit app it would still work fine however, as they would be sharing an address space. Your problem then is that not all APIs will work across this boundary.
Your best bet is probably to use FindWindow to detect when the Window is still active. You can do this by passing either the title of the window (the second parameter) or the class name of the window (which in this case is "MSPaintApp"), or both. Using the class is probably more robust if there will only be one instance running because the title will vary with the bitmap loaded. The call would look a bit like this:
Dim hWnd as integer
hWnd = FindWindow("MSPaintApp","untitled - Paint")
if hWnd <> 0 then
' App is still running.
end if
This should allow you to do what you want. Good Luck.
P.S. You can use GetClassName to give you the class of any window for which you have the hWnd. Check your API documentation for details.