请问我调用函数WaitForSingleObject后,一直返回一个WAIT_FAILED: Error: 0(&H0): 操作成功完成,请问是什么原因
解决方案 »
- 在VB6中读取IE保存的网站Cookie
- 求教高手们,关于jmail接收邮件
- 请问各位:一个有关获取数据库内信息的问题!
- 现求一sql语句的删选条件.
- 有没有函数可以从Html文本中分析出要在浏览器中显示的字符呀?
- vb&sql的使用問題???
- 请问如何实现VB调用带有登录函数并保存cookie的webservice
- 考勤时间判断!
- 怎样加入数据
- 请问在MSHFlexGrid中,时选定那写属性使单击鼠标时,被选定那行可以用蓝色显示出来?我找了很久还没有找到,要能整行选定的。谢谢
- 用VB写了一个基于DCOM的SERVER程序,ActiveX EXE自动注册了一个类,可是我的Active EXE中有几个类,是否要一一注册才可用???
- 水晶报表的页面设置和打印机设置
' (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
' and select Microsoft Common Dialog control)
Const INFINITE = &HFFFF
Const STARTF_USESHOWWINDOW = &H1
Private Enum enSW
SW_HIDE = 0
SW_NORMAL = 1
SW_MAXIMIZE = 3
SW_MINIMIZE = 6
End Enum
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private 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 Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Enum enPriority_Class
NORMAL_PRIORITY_CLASS = &H20
IDLE_PRIORITY_CLASS = &H40
HIGH_PRIORITY_CLASS = &H80
End Enum
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Function SuperShell(ByVal App As String, ByVal WorkDir As String, dwMilliseconds As Long, ByVal start_size As enSW, ByVal Priority_Class As enPriority_Class) As Boolean
Dim pclass As Long
Dim sinfo As STARTUPINFO
Dim pinfo As PROCESS_INFORMATION
'Not used, but needed
Dim sec1 As SECURITY_ATTRIBUTES
Dim sec2 As SECURITY_ATTRIBUTES
'Set the structure size
sec1.nLength = Len(sec1)
sec2.nLength = Len(sec2)
sinfo.cb = Len(sinfo)
'Set the flags
sinfo.dwFlags = STARTF_USESHOWWINDOW
'Set the window's startup position
sinfo.wShowWindow = start_size
'Set the priority class
pclass = Priority_Class
'Start the program
If CreateProcess(vbNullString, App, sec1, sec2, False, pclass, _
0&, WorkDir, sinfo, pinfo) Then
'Wait
WaitForSingleObject pinfo.hProcess, INFINITE
SuperShell = True
Else
SuperShell = False
End If
End Function
Private Sub Form_Load()
'Set the dialog's title
CDBox.DialogTitle = "Choose an EXEC-File ..."
'Error when canceled
CDBox.CancelError = True
'Set the dialog's filter
CDBox.Filter = "EXEC-Files (*.exe)|*.exe|All files (*.*)|*.*"
'Show the 'Open File'-dialog
CDBox.ShowOpen
'Execute the program
SuperShell CDBox.filename, Left$(CDBox.filename, Len(CDBox.filename) - Len(CDBox.FileTitle)), 0, SW_NORMAL, HIGH_PRIORITY_CLASS
End
End Sub
If the function succeeds, the return value indicates the event that caused the function to return. This value can be one of the following. Value Meaning
WAIT_ABANDONED The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled.
WAIT_OBJECT_0 The state of the specified object is signaled.
WAIT_TIMEOUT The time-out interval elapsed, and the object's state is nonsignaled.
If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError. Res
The WaitForSingleObject function checks the current state of the specified object. If the object's state is nonsignaled, the calling thread enters the wait state. It uses no processor time while waiting for the object state to become signaled or the time-out interval to elapse.The function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one. The WaitForSingleObject function can wait for the following objects: Change notification
Console input
Event
Job
Mutex
Process
Semaphore
Thread
Waitable timer