Solved

Creating ActiveX reference with the CLSID

Posted on 2001-07-13
12
506 Views
Last Modified: 2012-05-04
How can I get the app name and class name from the CLSID?  I want to do a CreateObject() but I don't know the application name and class of the object to create.  I only know the CLSID.  Thanks.
0
Comment
Question by:dfc106
12 Comments
 
LVL 3

Expert Comment

by:jrspano
Comment Utility
search the registry it should tell you.  hkey classes root and then look under appid they should be in there
0
 

Author Comment

by:dfc106
Comment Utility
I need to do this programmatically.  Searching the registry would be too slow.
0
 
LVL 3

Expert Comment

by:jrspano
Comment Utility
it is near instantaneous on a pentium 166.  that is a pretty slow cpu.  If you know the clsid in advance why don't you just find it in your registry and then code it in your project. where are you getting the clsid from?

as for programmatically I don't think that is possible.  the only place i know of on a cpu that that info is stored is the registry.
0
 

Author Comment

by:dfc106
Comment Utility
I don't know the clsid in advance.  I'm hoping there is some function to dig the value out of the registry for me.  I could write the function to do it, but I'm lazy, and it probably wouldn't be as efficient as it could be.
0
 
LVL 3

Expert Comment

by:jrspano
Comment Utility
if you don't know the clsid or the name of the component how do you know what to load at all??
0
 

Author Comment

by:dfc106
Comment Utility
I'm getting the clsid out of a database at runtime.  As far as searching the registry; try taking the clsid of the last entry in your hkey_classes_root key then search for it.  Way too slow.  I either need a function that can quickly locate it, or I need to know how I can search for it myself efficiently.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:jrspano
Comment Utility
is it your db?  if so modify it to include the componet names.  there isn't a way to just return the component name from the class id.  you are stuck with searching the registry.  If you use the registry api's it is fast.  you already know the location of the ids hkeyclassesroot/appid.
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
A quick look at my registry tells me that you can open the default value at either:

HKCR\CLSID\ & ClassIDFromDB
-or-
HKCR\CLSID\ & ClassIDFromDB & "\ProgID"

and that will be the name of what you can pass to CreateObject.

This gets me the name of my own components and several that aren't my own. A bit of practice should tell you which is more reliable...
0
 

Author Comment

by:dfc106
Comment Utility
Thanks guys but here is the answer I was looking for:

Private Declare Function ProgIDFromCLSID _
   Lib "ole32.dll" (pCLSID As GUID, lpszProgID As Long) As Long

There is a good example at:
http://support.microsoft.com/support/kb/articles/Q183/5/44.ASP
0
 
LVL 3

Expert Comment

by:jrspano
Comment Utility
cool you learn something every day!
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Hi dfc106,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

dfc106, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
Placed in PAQ

Computer101
E-E Moderator
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

743 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

18 Experts available now in Live!

Get 1:1 Help Now