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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registering DLL's at runtime (Retrieving CLSID) 1

Status
Not open for further replies.

zarkon4

MIS
Dec 16, 2003
641
US
I suppose my first question is Can this be done?
This is what I would like to do.

I have a directory with ActiveX Dll's, I would like to
go thru each Dll and check to see if it is registered in the registry, if it is NOT then I would execute a shell command to register it with regsvr32.exe

My question is How do I obtain the CLSID from the Dll, exp, or lib file in order to check the registry?

Or would it just be safer to unregister and register each one?


 
Reason being: Don't want to and feel I shouldn't have to go to every pc within the company just to register or unregister.
 
When you said "then I would execute a shell command to register it with regsvr32.exe" I thought you would have a little vb application to loop thru each dll in directory then register it.

The easy route being - loop thru each dll in directory unregister it then register it.
 
Well, if you look at the following source code you will find an app that finds and removes (by name eg: sample.dll) a specified .dll from the registry and unregister's it. You could easily modify the code to suit your needs. Look for the registry setting and not delete it, but add a new one if not found !!

 
"Don't want to and feel I shouldn't have to go to every pc within the company just to register or unregister."

Issue is you would have be at every pc to check anyway. Ie how would you identify that a PC has the entries? Actually if you are an admin on the network you can connect to every machines registry and look through but unless your companies machines are dispursed via a lot of distance then walking around to the machines, inserting a CD with a autorun.inf, waiting about 15 seconds then moving to the next machine will probably be alot faster.

I understand your issue from your other post. You have an app. You have 50 PC's. How do you register the components on the 50 PC's.

It has to be done. You either do this by going around with some portable medium (CD I'd suggest), or use a network drive accessible by all, or have some other process like SMS or login script do it for you.

But EVERY machine you run your app on needs the components regestered. And in your case they need to be registered to use the server. You haven't said if your components are using Component Services or not. If they are you needt to export the package(s) your components reside in and run that/those setups on all your client machines.

So my first question is "HOW do your components reside on your server? Are they in a Windows Service, an ActiveX EXE or ActiveX DLL running under CS."

Depending on that will dictate how you install the components. If you are running an activeX EXE then you'll have to mess with DCOMCNFG.

 
Thanks All! Is there a way to retrieve the CSLID from the DLL itself and not the registry? I am curious if the CSLID is being assigned by the Operating system or if it is stored internally when compiled? I know it's created when I compile which leads me to believe it's stored internally, unless, of course, it does not have binary compatability.
If it is stored internally, how do I retrieve it? Just curious.
 
Try this, you'll have to add error handling. You may want to do a google search on the tlbinf32.dll.

'add reference to TypeLib Information

Private Function GetCLSID(ByVal strPath As String) As String
Dim objTLB As TLI.TypeLibInfo
Set objTLB = TLI.TypeLibInfoFromFile(strPath)
If objTLB Is Nothing Then
MsgBox "No TypeLib info found."
Else
GetCLSID = objTLB.GUID
End If
End Function

Private Sub Command1_Click()
MsgBox GetCLSID("C:\Folder\Some.DLL")
End Sub
 
Thanks DrJavaJoe!!! Exactly what I was looking for!!!!!
 
All VB DLLs have the registry information stored internally. This is what REGSVR32.EXE uses to put the entries in the registry. It is possible to create ActiveX DLLs in other languages that don't have this information but that is rarely done.

The TLI library is great. If you ever want to dynamically call methods and get around the whole callbyname problems this is the library to use. Not straight forward but it can be done.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top