
32 bit equivalent of 16 bit API call GetModuleUsage
Quote:
> I have a 16 bit program that I now want to bring to 32 bit. The 16 bit
> uses the API Function GetModuleUsage. But this is not supported in 32 bit
> The code is something like this:
> handle = Shell(---- Prints a Fax-----)
> While GetModuleUsage(handle)> 0 then
> DoEvents
> Wend
> As the Faxes can be quite long I want it to wait until it's finished
> printing, before moving on to the next one.
> ANY IDEAS?
Try this:
handle = Shell("command.com /c " + "your command to print the fax",
1)
OpenProcess = OpenProcess(SYNCHRONIZE, True, handle)
Do While WaitForSingleObject(OpenProcess, 0) > 0
DoEvents
Loop
ret = TerminateProcess(OpenProcess, 0&)
ret = CloseHandle(OpenProcess)
MsgBox "Printing has terminated!"
Add the following declarations.
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal _
dwAccess As Long, ByVal fInherit As Integer, ByVal hObject _
As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal _
hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Const SYNCHRONIZE = 1048576