在VB6中如何调用API中的createthread函数?

songzx66 2001-09-03 05:16:27
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Boolean
End Type

Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal dwStackSize As Long, lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long

Public Function ThrPath(CurPath As String)
Dim threadid As Long, hnd As Long
dim lpThreadAttributes as SECURITY_ATTRIBUTES
hnd = CreateThread(lpThreadAttributes, 0&, AddressOf myfunction, ByVal myParm, ByVal 0&, threadid)
End Function


我不知道lpThreadAttributes应该给何值。线程才创建成功。


...全文
229 1 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
htu 2001-09-03

Private Sub Command1_Click()
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 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()
Sleep 10000
hThread = 0
End Sub
  • 打赏
  • 举报
回复
相关推荐
发帖
API

1476

社区成员

VB API
社区管理员
  • API
加入社区
帖子事件
创建了帖子
2001-09-03 05:16
社区公告
暂无公告