Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Timing web browser usage.
Message
From
16/07/2001 18:29:07
Jason Dalio
Northern Interior Regional Health Board
Prince George, British Columbia, Canada
 
 
To
15/07/2001 14:52:13
Sammy Derban
Ghana Telecom
Accra, Ghana
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00530800
Message ID:
00531289
Views:
10
The following code shells out to the application and retrieves the new windows handle value (the unique identifier to windows). It then puts itself into a holding pattern until the shelled window is terminated. So keep in mind that your VB execution is halted until the shelled window is closed. Cheers.

'the next 7 lines should be in the General Declarations section
Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFF
Const WAIT_OBJECT_0 = 0
Const WAIT_TIMEOUT = &H102
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

'Include the following block of code wherever you want
Dim lPid As Long
Dim lRet As Long
Dim lHnd As Long

lPid = Shell("c:\windows\notepad.exe", vbHide)
If lPid <> 0 Then
'Get a handle to the shelled process.
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)
'If successful, wait for the application to end and close the handle.
If lHnd <> 0 Then
lRet = WaitForSingleObject(lHnd, INFINITE)
CloseHandle (lHnd)
End If
End If
Previous
Reply
Map
View

Click here to load this message in the networking platform