Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Wait window
Message
De
22/01/2002 09:53:41
 
 
À
16/01/2002 15:05:02
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00605631
Message ID:
00608395
Vues:
16
James,

You can use this function that I created. It will wait forever unless change the parameter for the "WaitForSingleObject" from INFINATE to a millisecond value. There might be some more constant values that you need to get, but they would all be in the API Viewer that ships with VB.

Public Const INFINITE = &HFFFF ' Infinite timeout
Public Const STARTF_USESHOWWINDOW = &H1
Public Const SW_SHOWNORMAL = 1
Public Const CREATE_NEW_CONSOLE = &H10
Public Const NORMAL_PRIORITY_CLASS = &H20

Public Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type

Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Public Function WinExecuteAndWait(FileName As String) As Long
'************************************************************
'Pass in the entire path as the FileName.
'This will not return until the called application is done running and exits.
'************************************************************
Dim MyStartupInfo As STARTUPINFO
Dim MyProcessInfo As PROCESS_INFORMATION
Dim ProcessSecurity As SECURITY_ATTRIBUTES
Dim ThreadSecurity As SECURITY_ATTRIBUTES
Dim bRet As Boolean
Dim lExitCode As Long
Dim lCreateRet As Long
Dim lResult As Long

MyStartupInfo.dwFlags = STARTF_USESHOWWINDOW
MyStartupInfo.wShowWindow = SW_SHOWNORMAL
lCreateRet = CreateProcess(vbNullString, _
FileName, _
ProcessSecurity, _
ThreadSecurity, _
0, _
CREATE_NEW_CONSOLE Or NORMAL_PRIORITY_CLASS, _
"", _
vbNullString, _
MyStartupInfo, _
MyProcessInfo)
If lCreateRet = 0 Then
lResult = 0
Else
WaitForSingleObject MyProcessInfo.hProcess, INFINITE
' WaitForSingleObject MyProcessInfo.hProcess, 1000
bRet = GetExitCodeProcess(MyProcessInfo.hProcess, lExitCode)
If bRet Then
lResult = 1
Else
lResult = 0
End If
End If
WinExecuteAndWait = iResult
End Function
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform