我在做多线程的时候在调试阶段一切正常,但编译成exe文件运行就不对了,一创建线程就就出现exe非法操作。这是咱们回事??
一下是一些主要代码,各位高手帮忙看一下
Public Function CreateNewThread(ByVal cFunction As Long, Optional ByVal cPriority As Long = tpNormal, Optional ByVal cEnabled As Boolean = True)
'Creates a new Thread
Dim mHandle As Long
Dim CreationFlags As Long
Dim lpThreadID As Long
'Look if the thread has already been created
If mCreated = True Then Exit Function
'Look if the thread should be enabled
If cEnabled = True Then
CreationFlags = 0
Else
'Create a disabled thread, can be enabled later with the
''Enabled' property
CreationFlags = CREATE_SUSPENDED
End If
'The CreateThread Function returns the handle of the created thread;
'if the handle is 0, it failed creating the thread
mHandle = CreateThread(ByVal 0&, ByVal 0&, cFunction, ByVal 0&, CreationFlags, lpThreadID)
If mHandle = 0 Then 'Failed creating the thread
'Insert your own error handling
'Debug.Print "InitializeThread Function in clsThreading failed creating a new thread"
Else
mThreadHandle = mHandle
mThreadID = lpThreadID
mCreated = True
End If
End Function
一下是一些主要代码,各位高手帮忙看一下
Public Function CreateNewThread(ByVal cFunction As Long, Optional ByVal cPriority As Long = tpNormal, Optional ByVal cEnabled As Boolean = True)
'Creates a new Thread
Dim mHandle As Long
Dim CreationFlags As Long
Dim lpThreadID As Long
'Look if the thread has already been created
If mCreated = True Then Exit Function
'Look if the thread should be enabled
If cEnabled = True Then
CreationFlags = 0
Else
'Create a disabled thread, can be enabled later with the
''Enabled' property
CreationFlags = CREATE_SUSPENDED
End If
'The CreateThread Function returns the handle of the created thread;
'if the handle is 0, it failed creating the thread
mHandle = CreateThread(ByVal 0&, ByVal 0&, cFunction, ByVal 0&, CreationFlags, lpThreadID)
If mHandle = 0 Then 'Failed creating the thread
'Insert your own error handling
'Debug.Print "InitializeThread Function in clsThreading failed creating a new thread"
Else
mThreadHandle = mHandle
mThreadID = lpThreadID
mCreated = True
End If
End Function
http://www.china-askpro.com/msg2/qa20.shtml