Can I use a clsid in HKEY_CLASSES_ROOT\clsid ?
is it the clsid for COM ?
How can I use it ?
Printable View
Can I use a clsid in HKEY_CLASSES_ROOT\clsid ?
is it the clsid for COM ?
How can I use it ?
Thank you Victor,
But when I try to do use it along with a iid in statement like
CocreateInstance(clsid,....,iid_interface,&p);
it return "class has not been registered". I know this is basic but it is still difficult for me, could you offer more instructions, maybe a summary of actual uses of clsids which are provided by default (those included in MS'COM interfaces: IBrowser, IShelllink etc) and those that are not included. What can the user do to handle the latter in general.
People mention I have to queery the interface QueryInterface (method by IUnknown, clsid provided) or CreateInstance (Ifactoryclass, clsid not provided). I am thining i am in the middle of a cycle with no way out.
Then register it!
I am thinking those have been registered and I just would like to enumerate them. Well am I wrong ?
This is a short explanation for the most important Registry keys for COM http://mariusbancila.ro/blog/2010/06...-and-registry/. Also this is a good COM tutorial for beginners http://www.codeproject.com/KB/COM/comintro.aspx.
Now, can you explain what you're actually trying to do? Create a COM object? Enumerating some registry keys? It's not very clear.
Thank you for your replies.
My question is mainly about the CLSID
For example, in the link you provide
or thisCode:hr = CoCreateInstance ( CLSID_ActiveDesktop,
NULL,
CLSCTX_INPROC_SERVER,
IID_IActiveDesktop,
(void**) &pIAD );
You see the CLSIDs of coclass, they are both predefined in the given COM interfaces' header files, in particular in this case it is IShellLink and IActiveDesktopCode:
hr = CoCreateInstance ( CLSID_ShellLink, // CLSID of coclass
NULL, // not used - aggregation
CLSCTX_INPROC_SERVER, // type of server
IID_IShellLink, // IID of interface
(void**) &pISL ); // Pointer to our interface pointer
Now there are interfaces in the library that do not have such CLSID_XXXXX. So I can't use CoCreateInstance. Someone advised me to use QuerryInterface or CreateInstance. The former method is inherited from IUnknown and yes I am unknown of how it is used as if I put it like
IUnknown*p;
p->QueryInterface(iid, *somepointerToTheInterface_I_want)
Then this reports an error because IUnknown is abstract.
In case of the latter, CreateInstance is a method from IFactoryClass but inorder to use this interface right in the first place I need a pointer to it to get activated, or an instance of that interface must be invoked, but again I need to create a CLSID of IFactoryClass that is NOT included in any header files
But you have to tell people what you are doing so they can advise. Sometimes you need to create a pointer to some interface that has the Clisd for you to use CoCreateInstance and this class again has a method call to create your wanted interface's instance.
Predefined never means it was defined miraculously and you never can know how it was done. It's just a GUID structure you could initialize yourself with proper CLSID data. The same to IID.
:) Yes, you can. And your question should be how to make that CLSID definition.Quote:
Now there are interfaces in the library that do not have such CLSID_XXXXX. So I can't use CoCreateInstance.
QueryInterface can not be used instead of CoCreateInstance. Period. Start learning COM basics by trusted authors. Dale Rogerson for example.Quote:
Someone advised me to use QuerryInterface or CreateInstance.
Thank you,
What do you mean by Yes I can ?
My questions are not how to make CLSID or IID. My previous post was to explain to cilu about what I would like to know.
You sound like an expert of COM. Would you please offer a summary within 15 lines of the COM basics I would need to learn, especially in ralation to my current problem ? I will invest some time searching for keywords as well as hints you introduce me then.
I live in a third world country, Enlgish books are so expensive to me.
I would recommend reading carefully that COM tutorial that I pointed. Among others it explains what CLSID (a GUID for a coclass) and IID (a GUID for an interface) are. It also explains what QueryInterface and CoCreateInstance do.
Literally, you said you can not (because of whatever you thought), and I said yes you can even without headers. Very simple statement.
I said not "to make", I said "initialize CLSID sruct" like the headers do, to be used in CoCreateInstance. I understood the lack of headers is your problem, so you always can make the headers yourself. :)Quote:
My questions are not how to make CLSID or IID.
Sorry, but I cannot see any question in the post. Now you have to change something in your approach of asking and find a way to ask your questions in less vague manner if you want to yield something from this discussion.Quote:
My previous post was to explain to cilu about what I would like to know.
Well, I live in Russia which isn't first world country either, but in my time I've managed to find Rogerson's book Russian edition. ;) And I would not dare to try to squeeze COM basics into 15 line summary even with the fact I really have some experience in COM. Actually, the book is the shortest COM basics explanation I ever met. And it certainly has more than 15 lines.Quote:
You sound like an expert of COM. Would you please offer a summary within 15 lines of the COM basics I would need to learn, especially in ralation to my current problem ? I will invest some time searching for keywords as well as hints you introduce me then.
I live in a third world country, Enlgish books are so expensive to me.