Solved

Creating ActiveX reference with the CLSID

Posted on 2001-07-13
12
515 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 3

Expert Comment

by:jrspano
ID: 6281554
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
ID: 6281576
I need to do this programmatically.  Searching the registry would be too slow.
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6281589
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dfc106
ID: 6281625
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
ID: 6281631
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
ID: 6281661
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
 
LVL 3

Expert Comment

by:jrspano
ID: 6281692
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
ID: 6282524
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
ID: 6282750
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
ID: 6285521
cool you learn something every day!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7153419
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
ID: 7182144
Placed in PAQ

Computer101
E-E Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

734 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