Solved

Registry Problem

Posted on 1998-05-28
3
217 Views
Last Modified: 2012-06-22
Hi,

This is Vasudevan S from San Jose, CA working on a Version
Control System project in VB5.0(Professional Edt).

I got a critical problem during my development.
The problem is "How do I check whether a ActiveX DLL/OCX has been
registered in the system registry?"

I followed some techniques which I believe is not concrete for all types of ActiveX components.

The techniques that I followed is

I did a Enum of all InprocServer32 entries in HKEY_CLASSES_ROOT
key to get the path since any ActiveX DLL/OCX has a InprocServer32
key. Is this always true?

I found to my dismay that MSVBVM50.DLL (although its a ActiveX DLL)
when registered with regsvr32.exe tool does not write any entries
in InprocServer32 key. Instead it writes in HKEY_LOCAL_MACHINE\Software\Classes\TypeLib\<some typelib entry>\5.0\0\win32. This entry has a fully qualified path.

My requirement is my clients will select any file at runtime using
Common Dialog OCX and for each file I need to check whether it has
been registered properly. If not I will ask him to register.

I have checked whether any DLL/OCX is a ActiveX component by
checking for the DllRegisterServer entry point using GetProcAddress
SDK call. I couldn't proceed any further as I'm struck here.

I would very much appreciate if you would help me with any best
possible solution.

Regards,

Vasudevan S,
San Jose,
CA 95136.
0
Comment
Question by:vass
3 Comments
 

Author Comment

by:vass
ID: 1461963
Edited text of question
0
 
LVL 1

Expert Comment

by:sirigere
ID: 1461964
You can go for checking for a classids.
0
 
LVL 4

Accepted Solution

by:
yowkee earned 180 total points
ID: 1461965
vass,

  This problem has stay for a while and you might have found your solution. However, I do some research and come out something.

  First, for component which implement their COM interface for access by others, they do have key "InProcServer32" under HKCR\CLSID. It is not always true for all ActiveX Component with extension .DLL, .OCX. Actually files with .dll, .ocx, .tlb are all dynamic linking library and they implement their DllRegisterServer themselves.

  I do believe MSVBVM50.dll is kind of type library. The purpose of type library is doing marshaling to get COM interface under different process. They need not implement their own COM interface for access, that's why they only have key under HKCR\Typelib (HKLM\Software\Classes is same to HKCR). Those ActiveX component who implement own interface would also have their type library for marshaling.

  It seem what I try to say is confusing. Let's said, ActiveX component which implement their own COM interface will have keys under HKCR\CLSID, HKCR\Interface, HKCR\Typelib. And type library DLL only have key under HKCR\Typelib (eg. MSVBVM50.dll. stdole2.tlb do have key under HKCR\CLSID, it is type library for oleaut32.dll).

  Hope you are clearer yet(my english is poor).
  No matter how, my solution is:
 
  You could enumerate all "InProcServer32" key under HKCR\CLSID and "win32" Key under HKCR\TypeLib for checking whether a ActiveX DLL/OCX registered or not.
  If you want to handle ActiveX exe too. You should check key "LocalServer32" under HKCR\CLSID. And key "AppID" under HKCR\CLSID for remote COM interface(DCOM).

  As I think, a better way is using GetClsidFromActXFile to get the CLSID of the ActiveX component(exe/dll/ocx/tlb). Then check whether HKCR\CLSID\{The CLSID you get} existed. If it do exist, then the ActiveX component has been registered. If not, enumerate all "win32" key to check whether this component is just a type library. If still can't find the select file under HKCR\TypeLib, then it is not register yet.

  Example of using GetClsidFromActXFile:

--
Private Declare Function GetClsidFromActXFile Lib "VB5STKIT.DLL" (ByVal pszFilename As String, ByVal pszProgID As String, ByVal pszClsid As String) As Long

Private Sub Command1_Click()
    Dim sFile As String
    Dim sProgID As String
    Dim sClsid As String * 256
    Dim lRtn As Long
   
    sFile = "C:\windows\system\stdole2.tlb"

    ' even did not pass anything in 2nd parameter, it will
    ' still get the CLSID. If the ActiveX component implement
    ' more than one interface, a second call to
    ' GetClsidFromActXFile will get another CLSID. It is
    ' due to we did not pass the specified ProgID to get CLSID.  
    lRtn = GetClsidFromActXFile(sFile, sProgID, sClsid)
    Debug.Print Left$(sClsid, InStr(sClsid, Chr$(0)))

End Sub
--

Note: There might have one ActiveX component being registered and did not have key "InProcServer32", "LockServer32" under HKCR\CLSID. For example, I write a ActiveX DLL with only one Class with property is "PublicNotCreatable" (in VB5). Then after registered, we won't find those key under its CLSID, since it didn't implement any public interface. Of course such ActiveX component normally is useless.

Hope this help.  :)

Regards.



0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question