Here is the code.
Dim process, regLib, succeed As Integer
Dim xc, h1, id As Integer
Dim p As String
Select Case func
Case regxEnum.REGISTER
p = "DllRegisterServer"
Case regxEnum.UNREGISTER
p = "DllUnregisterServer"
Case Else
Return resultEnum.INVALID
End Select
regLib = LoadLibraryRegister(Path)
If regLib = 0 Then
Return resultEnum.NOTFOUND
End If
'get the address for either the Register or Unregister
process = GetProcAddressRegister(regLib, p)
If process = 0 Then
FreeLibraryRegister(regLib)
Return resultEnum.NOTACTX
Else
h1 = CreateThreadForRegister(0, 0, process, 0, 0, id)
'unable to create a thread for register or unregister
If h1 = 0 Then
FreeLibraryRegister(regLib)
Return resultEnum.NOTHREAD
Else
succeed = (WaitForSingleObject(h1, 2000) = 0)
If succeed Then
CloseHandle(h1)
FreeLibraryRegister(regLib)
Return resultEnum.SUCCESS
Else
GetExitCodeThread(h1, xc)
ExitThread(xc)
FreeLibraryRegister(regLib)
Return resultEnum.FAILURE
End If
End If
End If
Here is the problem:
I have a program running this code segment on lots of different
machines. However, on only 3 machines this code segment fails. I
have been able to track it down to when ExitThread(xc) is called, it
never returns. The value of xc when this API is called is 259. I am
a very green newbie with threading and am thoroughly confused by this.
I thought, since xc = 259, that means the thread is still running.
Shouldn't ExitThread just kill the thread? Am I missing something
important here? I would love to have some help in understanging this.
As always, thank you very much for your help.
Kalvin