Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Similarly, using the intrinsic Shell() function:</p> <pre><code>Private Const INFINITE = &amp;HFFFF Private Const SYNCHRONIZE = &amp;H100000 Private Const PROCESS_QUERY_INFORMATION = &amp;H400 Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" ( _ ByVal hProcess As Long, _ lpExitCode As Long) As Long 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 Function SyncShell( _ ByVal PathName As String, _ ByVal WindowStyle As VbAppWinStyle) As Long 'Shell and wait. Return exit code result, raise an 'exception on any error. Dim lngPid As Long Dim lngHandle As Long Dim lngExitCode As Long lngPid = Shell(PathName, WindowStyle) If lngPid &lt;&gt; 0 Then lngHandle = OpenProcess(SYNCHRONIZE _ Or PROCESS_QUERY_INFORMATION, 0, lngPid) If lngHandle &lt;&gt; 0 Then WaitForSingleObject lngHandle, INFINITE If GetExitCodeProcess(lngHandle, lngExitCode) &lt;&gt; 0 Then SyncShell = lngExitCode CloseHandle lngHandle Else CloseHandle lngHandle Err.Raise &amp;H8004AA00, "SyncShell", _ "Failed to retrieve exit code, error " _ &amp; CStr(Err.LastDllError) End If Else Err.Raise &amp;H8004AA01, "SyncShell", _ "Failed to open child process" End If Else Err.Raise &amp;H8004AA02, "SyncShell", _ "Failed to Shell child process" End If End Function </code></pre>
 

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