Image of Navigational Panel mapped to Contents / Home / Search VB Shelling
Tech Support Question

Image of Line Break

Q. I need to shell a 32bit app (in particular Win95 pbrush.exe) from a 16bit app. I need to wait for the pbrush to terminate before I can continue the 16Bit app.

The 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

A. Your problem basically is that when the 16bit app starts up the 32bit app the 16bit subsystem actually requests that the 32bit system opens the app.

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.


Image of Arrow to Previous Article Image of Arrow to Next Article

[TECH SUPPORT TOC]
Image of Line Break
[HOME] [TABLE OF CONTENTS] [SEARCH]