Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expert Help Needed - tlbinf32 - registering dlls - vb

Status
Not open for further replies.

zarkon4

MIS
Dec 16, 2003
641
US
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
 
These are your own ActiveX DLLs? Written in VB? If so, then this may actually be easier than you are currently making it. Check out my comments (and further link) in thread222-597373
 
Thanks strongm, but I already know how to do that. The problem started when some dlls would not register that way, so I came up with an alternative. If I manually register them, then it works. If I use a function declaration or the code above, then some of them don't register, and it is intermittent. One dll (I'll call it mydll.dll) will register on some 2000 machines and on some NT machines and will register on all XP machines. That is where the confusion is occurring. Why will it register on only some and not others? I am hoping someone has encountered this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top