VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

ShellExecuteWait

BioHazardMX  (4 Submissions)   Windows API Call/Explanation   Advanced   Wed 3rd February 2021

This code uses simple API to launch a program or a document but this code also awaits until the process has ended so you can force the user to do something before proceeding (as setup wizards does). The procedure supports command line parameters, a working folder and showing options.
It's so simple and I couldn't find it on this site so I posted it.

Returns
The code returns the hInstance of the new process if sucessfull or the error code if something gone wrong.

API Declarations
Private Const INFINITE As Long = &HFFFFFFFF
Private Const SEE_MASK_FLAG_NO_UI As Long = &H400
Private Const SEE_MASK_NOCLOSEPROCESS As Long = &H40
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hWnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Private Declare Function WaitForSingleObject Lib "Kernel32.dll" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function GetLastError Lib "Kernel32.dll" () As Long
Private Declare Function ShellExecuteEx Lib "Shell32.dll" (ByRef lpExecInfo As SHELLEXECUTEINFO) As Long

Rate ShellExecuteWait (2(2 Vote))
ShellExecuteWait.bas

ShellExecuteWait Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters