Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will need to use Win32 API calls to <a href="http://msdn.microsoft.com/en-us/library/bb762154(VS.85).aspx" rel="noreferrer">ShellExecuteEx</a> and WaitForSingleObject on the process handle returned from ShellExecuteEx in the SHELLEXECUTEINFO structure. This is old code which I've pulled out of a project. It was working 100% but I may not have included all dependencies. You should be able to edit to your requirements:</p> <pre><code> 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 ' Optional fields' lpIDList As Long lpClass As String hkeyClass As Long dwHotKey As Long hIcon As Long hProcess As Long End Type Public Declare Function ShellExecuteEx Lib "shell32.dll" (lpExecInfo As SHELLEXECUTEINFO) As Long Public Declare Function apiShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" _ (ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) _ As Long Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Public Const SEE_MASK_NOCLOSEPROCESS As Long = &amp;H40 Public Const SEE_MASK_FLAG_DDEWAIT As Long = &amp;H100 '***App Window Constants***' Public Const WIN_NORMAL = 1 'Open Normal' Public Const WIN_MAX = 2 'Open Maximized' Public Const WIN_MIN = 3 'Open Minimized' '***Error Codes***' Private Const ERROR_SUCCESS = 32&amp; Private Const ERROR_NO_ASSOC = 31&amp; Private Const ERROR_OUT_OF_MEM = 0&amp; Private Const ERROR_FILE_NOT_FOUND = 2&amp; Private Const ERROR_PATH_NOT_FOUND = 3&amp; Private Const ERROR_BAD_FORMAT = 11&amp; ' Returns 'True' if file was opened ...' Public Function fHandleFile(ByVal stFile As String, _ ByVal lShowHow As Long, _ ByRef stRet As String, _ Optional ByVal bWaitForClose As Boolean = False) As Boolean On Error GoTo err_Handler Dim lRet As Long Dim ret As Long Dim lngProcessHandle As Long Dim varTaskID As Variant Dim shInfo As SHELLEXECUTEINFO Dim retval As Long 'First try ShellExecute' With shInfo .cbSize = LenB(shInfo) .lpFile = stFile .nShow = lShowHow If bWaitForClose Then .fMask = SEE_MASK_FLAG_DDEWAIT + SEE_MASK_NOCLOSEPROCESS End If .lpVerb = "open" End With Call ShellExecuteEx(shInfo) lRet = shInfo.hInstApp If lRet &gt; ERROR_SUCCESS And bWaitForClose = True Then lngProcessHandle = shInfo.hProcess Do retval = WaitForSingleObject(lngProcessHandle, 0) DoEvents Loop Until retval &lt;&gt; 258 ret = CloseHandle(lngProcessHandle) End If fHandleFile = (lRet &gt; 0) exit_handler: Exit Function err_Handler: RaiseError Err.Number, Err.Source, Err.Description End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload