Solved

Creating ActiveX reference with the CLSID

Posted on 2001-07-13
12
514 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
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
Industry Leaders: 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 140
MS Date Picker 64 bit 32 bit issue 12 63
pop out of webbrowser1 control vba6 5 41
Sub or Function is not defined 6 50
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

679 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