Solved

Creating ActiveX reference with the CLSID

Posted on 2001-07-13
12
508 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

910 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

27 Experts available now in Live!

Get 1:1 Help Now