Solved

Registry Problem

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now