ProgramID = Shell(lpCmdLine, nCmdShow)
hProgram = OpenProcess(SYNCHRONIZE, False, ProgramID)
If hProgram <> 0 Then
Call WaitForSingleObject(hProgram, WAIT_TIMEOUT)
Call CloseHandle(hProgram)
End If
hProgram = OpenProcess(SYNCHRONIZE, False, ProgramID)
If hProgram <> 0 Then
Call WaitForSingleObject(hProgram, WAIT_TIMEOUT)
Call CloseHandle(hProgram)
End If
给出的代码运行有错,有几个函数未定义,能否将代码写全一点,谢谢!
如:
dim a as integer
a=shell("C:\format C:/q/u")
我已试过此方法,结果不行!
Dim o_ProcName As PROCESS_INFORMATION
Dim o_NameStart As STARTUPINFO
Dim o_ProcessHandle As Long
o_NameStart.cb = Len(o_NameStart)
o_NameStart.wShowWindow = 0
o_ProcessHandle = CreateProcessA(0&, _
vCommandLine, _
0&, _
0&, _
1&, _
NORMAL_PRIORITY_CLASS Or CREATE_NO_WINDOW, _
0&, _
0&, _
o_NameStart, _
o_ProcName)
o_ProcessHandle = WaitForSingleObject(o_ProcName.hProcess, INFINITE)
o_ProcessHandle = CloseHandle(o_ProcName.hProcess)
End Function
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
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 Const NORMAL_PRIORITY_CLASS As Long = &H20&
Public Const CREATE_NO_WINDOW As Long = &H8000000
Public Const INFINITE = -1&
Public Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
Public Declare Function WaitForSingleObject _
Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Public Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, _
ByVal lpCommandLine As String, _
ByVal lpProcessAttributes As Long, _
ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, _
ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long