1.Any code you write to call a function pointer from Visual Basic must be placed in a standard .BAS module — you can't put the code in a class module or attach it to a form.
解决方案 »
- DBGRID如何在CLICK事件中获取当前行对应列的值? 菜鸟在线等
- UTF-8如何转换成GB2312并显示?急....在线等
- 数据库删除问题?
- 关于打包问题(回者有分!!!!!!!!!1)
- 如何获取当前活动窗体中插入符(键盘光标Caret)的高度?
- [请教] VB中如何监测IE被启动的事件
- 大家说说:用ADO连接局域网中机子的ACCESS数据库的问题?
- 如何保存或复制Microsoft Outlook面板中的自定义快捷方式?
- 请问如何在word文档中输入分号?小女子在此先谢谢各位高手!
- InstallShield创建的快捷方式为何不运行?
- 冰河4.0原码赠送........
- 有没有人做过供电局的数据采集系统?
Dim lpThreadId As Long
Dim THandle As Long
Dim myNull As Long
myNull = 0
THandle = CreateThread(myNull, 0, AddressOf ThreadFunc, 123, 0, lpThreadId)
If THandle = 0 Then
MsgBox "Cannot create thread"
End IfEnd Sub.BAS模块
Option Explicit
Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End TypePublic Type PARAM_TYPE
lValue As Long
End TypePublic Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function CreateThread Lib "kernel32" (ByRef lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long
Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Function ThreadFunc(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!"ThreadFunc = -2
End Function
另外,线程函数没办法返回你需要的值,但是可以用PostMessage给窗口发消息。
2.CreateThread(lnull, lstacksize, (AddressOf MyFunc), lnull, lCreationFlags,
^^^^^参数是放在这的,注意它只是一个指针。
lpThreadID)