代码如下:
Option Explicit
Public Declare Function CreateThread Lib "kernel32" _
(ByVal lpThreadAttributes As Long, _
ByVal dwStackSize As Long, _
ByVal lpStartAddress As Any, _
ByRef lpParameter As Any, _
ByVal dwCreationFlags As Long, _
ByRef lpThreadId As Long) As Long
Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Type PARAM_TYPE
lValue As Long
End Type
Function DaThreadFunc(ByRef lpParam As PARAM_TYPE) As Long
Dim szStr As String
szStr = "Thread value:" & CStr(lpParam.lValue) & vbNewLine & _
"Thread ID: " & CStr(GetCurrentThreadId)
MsgBox szStr, , "Function Cool!"
DaThreadFunc = -2
End Function
Sub Main()
Dim lRet As Long
Dim lThreadID As Long
Dim stParam As PARAM_TYPE
Dim szStr As String