VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

LaunchAppSynchronous

Darrell Sparti, MCSD  (2 Submissions)   Windows API Call/Explanation   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

Unlike the Shell command in VB which launches an application
asynchronous, this will launch the program synchronous.
What that means is that the shell execute command will launch
an application but not wait for it to execute before processing
the next line of code. This code will launch a program then
wait until the executable has terminated before executing the
next line of code.

Inputs
INPUT: The executables full path and name.

Returns
RETURN: True upon termination if successful, false if not.

API Declarations
Private Const INFINITE = &HFFFFFFFF
Private Const NORMAL_PRIORITY_CLASS = &H20
Private Const WAIT_TIMEOUT = &H102&
'
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
'
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
'
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
'
Private Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
'
Private Declare Function CreateProcessByNum Lib "kernel32" Alias "CreateProcessA" _
(ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes _
As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags _
As Long, lpEnvironment As Any, ByVal lpCurrentDirectory As String, lpStartupInfo As _
STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
'
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
'

Rate LaunchAppSynchronous (17(17 Vote))
LaunchAppSynchronous.bas

LaunchAppSynchronous Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters