My brain is totally baffled and I am in need of some expert help. All of our apps and dlls that we are writing are on a server, users run these from the server through a short cut on the desktop that allows a user to login (so to speak) and run the various apps. These users have a mix of OS (NT, 2000 and XP). I have devised a way to have the dlls registered at runtime from within the login app.
I use TLBINF32.DLL, Windows Scripting and a shell call to regsvr32.exe to do the actual registering of a dll.
The code is posted below for viewing. What it does is searches the DLL directory and checks to see if a DLL has been registered, if not then it will register it.
The problem I am having is that not all of them are getting registered, the XP machines seem to be registering all them fine, the NT and 2000 machines are not, and is intermittent. One dll will register on an NT machine but not a 2000 and in some cases the same dll will register on a 2000 and not NT. I have not been able to figure this out and am beginning to wonder if the issue is with TLBINF32 or if my code is wrong. Someone please help.
The code:
Public Function CheckDLLRegistry() As Boolean
Dim objTypeInfo As TLI.TypeLibInfo
Dim objRegInfo As TLI.TypeLibInfo
Dim objFSO As FileSystemObject
Dim objFolder As Folder
Dim objFile As File
Dim lResult As Long
On Error GoTo DLLNotRegistered
Set objFSO = New FileSystemObject
'DEFAULT_EXE is the location on the server
' ie: "\\Server\Directory\"
Set objFolder = objFSO.GetFolder(DEFAULT_EXE & "ActiveXDlls")
For Each objFile In objFolder.Files
If Mid(objFile.Path, Len(objFile.Path) - 3) = ".dll" Then
'Get information from type library
Set objTypeInfo = TypeLibInfoFromFile(objFile.Path)
Set objRegInfo = TypeLibInfoFromRegistry objTypeInfo.Guid, _
objTypeInfo.MajorVersion, objTypeInfo.MinorVersion, _
objTypeInfo.LCID)
Set objRegInfo = Nothing
Set objTypeInfo = Nothing
End If
Next
Set objFolder = Nothing
Set objFSO = Nothing
CheckDLLRegistry = True
Exit Function
DLLNotRegistered:
If Err.Number = tliErrTypeLibNotRegistered Then
'then shell execute DLLRegSvr32 /S {DLL}
lResult = Shell("RegSvr32.exe /S" & objFile.Path, vbHide)
Resume Next
Else
MsgBox "The following Error has occurred:" & vbCrLf & _
Err.Number & "-" & Err.Description, vbCritical + vbOKOnly, "ERROR"
Set objRegInfo = Nothing
Set objTypeInfo = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
CheckDLLRegistry = False
End If
End Function
I use TLBINF32.DLL, Windows Scripting and a shell call to regsvr32.exe to do the actual registering of a dll.
The code is posted below for viewing. What it does is searches the DLL directory and checks to see if a DLL has been registered, if not then it will register it.
The problem I am having is that not all of them are getting registered, the XP machines seem to be registering all them fine, the NT and 2000 machines are not, and is intermittent. One dll will register on an NT machine but not a 2000 and in some cases the same dll will register on a 2000 and not NT. I have not been able to figure this out and am beginning to wonder if the issue is with TLBINF32 or if my code is wrong. Someone please help.
The code:
Public Function CheckDLLRegistry() As Boolean
Dim objTypeInfo As TLI.TypeLibInfo
Dim objRegInfo As TLI.TypeLibInfo
Dim objFSO As FileSystemObject
Dim objFolder As Folder
Dim objFile As File
Dim lResult As Long
On Error GoTo DLLNotRegistered
Set objFSO = New FileSystemObject
'DEFAULT_EXE is the location on the server
' ie: "\\Server\Directory\"
Set objFolder = objFSO.GetFolder(DEFAULT_EXE & "ActiveXDlls")
For Each objFile In objFolder.Files
If Mid(objFile.Path, Len(objFile.Path) - 3) = ".dll" Then
'Get information from type library
Set objTypeInfo = TypeLibInfoFromFile(objFile.Path)
Set objRegInfo = TypeLibInfoFromRegistry objTypeInfo.Guid, _
objTypeInfo.MajorVersion, objTypeInfo.MinorVersion, _
objTypeInfo.LCID)
Set objRegInfo = Nothing
Set objTypeInfo = Nothing
End If
Next
Set objFolder = Nothing
Set objFSO = Nothing
CheckDLLRegistry = True
Exit Function
DLLNotRegistered:
If Err.Number = tliErrTypeLibNotRegistered Then
'then shell execute DLLRegSvr32 /S {DLL}
lResult = Shell("RegSvr32.exe /S" & objFile.Path, vbHide)
Resume Next
Else
MsgBox "The following Error has occurred:" & vbCrLf & _
Err.Number & "-" & Err.Description, vbCritical + vbOKOnly, "ERROR"
Set objRegInfo = Nothing
Set objTypeInfo = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
CheckDLLRegistry = False
End If
End Function