windows2003 用 api 创建不了线程
'问题很奇怪: 在IDE环境运行正常,可以创建线程;编译成EXE后,一运行程序就会自动结束,什么提示也没有.
'操作系统为 windows2003 + sp1,VB6.0中文企业版
'代码如下:
'Using the CreateThread function in Visual Basic
'is very risky! VB5 is 'kinda' stable, but VB6
'applications will probably crash when you
'use the CreateThread function.
'In a form
'Add a command button to the form
Private Sub Command1_Click()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'After you click this button, try to move the window
'You will see that the AsyncThread-function was executed asynchronously
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf AsyncThread, ByVal 0&, ByVal 0&, hThreadID)
CloseHandle hThread
End Sub
Private Sub Form_Unload(Cancel As Integer)
'If the thread is still running, close it
If hThread <> 0 Then TerminateThread hThread, 0
End Sub
'In a module
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public hThread As Long, hThreadID As Long
Public Sub AsyncThread()
'Let this thread sleep for 10 seconds
Sleep 10000
hThread = 0
End Sub
'操作系统为 windows2003 + sp1,VB6.0中文企业版
'代码如下:
'Using the CreateThread function in Visual Basic
'is very risky! VB5 is 'kinda' stable, but VB6
'applications will probably crash when you
'use the CreateThread function.
'In a form
'Add a command button to the form
Private Sub Command1_Click()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'After you click this button, try to move the window
'You will see that the AsyncThread-function was executed asynchronously
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf AsyncThread, ByVal 0&, ByVal 0&, hThreadID)
CloseHandle hThread
End Sub
Private Sub Form_Unload(Cancel As Integer)
'If the thread is still running, close it
If hThread <> 0 Then TerminateThread hThread, 0
End Sub
'In a module
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public hThread As Long, hThreadID As Long
Public Sub AsyncThread()
'Let this thread sleep for 10 seconds
Sleep 10000
hThread = 0
End Sub
...全文
相关推荐
Windows 2003 DDK
Windows 2003 DDK
Windows 2003 Platform SDK amd64
Windows 2003 PlatformSDK,支持x86,、amd64、ia64处理器,解压后使用虚拟光驱挂载后运行Setup.Exe即可安装。
Windows Nt 2003 NativeApi Reference中文版
因为是 pdg 转pdf而且 原pdg质量不是很高,所以此书质量也不高,但是还是可以算是不影响使用的
Windows 2003 TCP/IP
Windows 2003 TCP/IP Guide. It is helpful to understand how Windows TCP/IP configuration.
深入解析Windows操作系统 第4版——Microsoft Windows Server 2003/Windows XP/Windows 2000技术内幕
深入解析Windows操作系统 第4版——Microsoft Windows Server 2003/Windows XP/Windows 2000技术内幕全书


API
