Solved

Registry Problem

Posted on 1998-05-28
3
218 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 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