fWait
Shells an app, then waits for that app to close before it continues processing.
AI
Résumé par IA: 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.
Code source
Private Sub Command1_Click()
Dim sCmdLine As String
Dim idProg As Long, iExit As Long
sCmdLine = fGetWinDir & "\notepad.exe"
idProg = Shell(sCmdLine)
iExit = fWait(idProg)
If iExit Then
MsgBox "Something very, very bad just happened."
Else
MsgBox "Finished processing Notepad."
End If
End Sub
Function fWait(ByVal lProgID As Long) As Long
' Wait until proggie exit code <> STILL_ACTIVE&
Dim lExitCode As Long, hdlProg As Long
' Get proggie handle
hdlProg = OpenProcess(PROCESS_ALL_ACCESS, False, lProgID)
' Get current proggie exit code
GetExitCodeProcess hdlProg, lExitCode
Do While lExitCode = STILL_ACTIVE&
DoEvents
GetExitCodeProcess hdlProg, lExitCode
Loop
CloseHandle hdlProg
fWait = lExitCode
End Function
Private Function fGetWinDir() As String
' Wrapper to return OS Path
Dim lRet As Long, lSize As Long, sBuf As String * 512
lSize = 512
lRet = GetWindowsDirectory(sBuf, lSize)
fGetWinDir = Left(sBuf, InStr(1, sBuf, Chr(0)) - 1)
End Function
Commentaires originaux (3)
Récupéré via Wayback Machine