Private Function RegX(fName$, func%) As Integer
Dim regLib&, process&, succeed&
Dim h1&, xc&, id&
Dim p$
Select Case func
Case 0: p = "DllUnregisterServer"
Case 1: p = "DllRegisterServer"
Case Else: RegX = 0
Exit Function
End Select
regLib = LoadLibraryRegister(fName)
If regLib = 0 Then
RegX = 1
Exit Function
End If
process = GetProcAddressRegister(regLib, p)
If process = 0 Then
RegX = 2
Else
h1 = CreateThreadForRegister(ByVal 0&, 0&, _
ByVal process, ByVal 0&, 0&, id)
If h1 = 0 Then
RegX = 3
Else
succeed = (WaitForSingleObject(h1, 10000) = 0)
If succeed Then
CloseHandle h1
RegX = 4
Else
GetExitCodeThread h1, xc
ExitThread xc
RegX = 5
End If
End If
End If
FreeLibraryRegister regLib
End Function