Best Shell & Wait (No API's!)
Makes it easy to perform a clean "Shell & Wait" where your applicatoin kicks off an external application and waits for it to return before continuing. Many shell & wait examples I have found tend to overdrive the proccessor in a loop or require you to make API calls. This one uses the Windows Script object to take advantage of it's built-in wait parameter on the .Run method...scripting's version of Shell.
AI
AI Samenvatting: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Broncode
Upload
Function ShellAndWait(FileName As String)
Dim objScript
On Error GoTo ERR_OpenForEdit
Set objScript = CreateObject("WScript.Shell")
' Open a file for editing in Notepad and wait for return.
'The second parameter (after the FileName) is the Display Mode (normal w/focus,
'minimized...even hidden. For more info visit:
'http://msdn.microsoft.com/scripting/windowshost/doc/wsMthRun.htm
' The third parameter is the "Wait for return" parameter. This should be set to
' True for the Wait.
ShellApp = objScript.Run(FileName, 1, True)
ShellAndWait = True
EXIT_OpenForEdit:
Exit Function
ERR_OpenForEdit:
MsgBox Err.Description
GoTo EXIT_OpenForEdit
End Function
Originele reacties (3)
Hersteld van de Wayback Machine