Solved

Getting CLSID for server COM in VC++

Posted on 2003-10-27
4
674 Views
Last Modified: 2012-05-04
I am using a dll SocketX.dll in my applciation.
I am using as follows:
hresult=CLSIDFromProgID(OLESTR("SocketXObjLib.ISocketXObj"), &clsid);    //retrieve CLSID of component
   if (hresult==S_OK)
    return TRUE;
 ISocketXObj  *t;
 hresult=CoCreateInstance(clsid,NULL,CLSCTX_ALL,__uuidof(ISocketXObj),(LPVOID *) &t);
if(FAILED(hresult))
 return FALSE;
I am not gettin  the CLSID of this .I am getting null values
I have some uuid defined in the SocketX.tlh file.
The namespace given is SocketXObjLib and I have  some interfaces derived from IDispatch which is defined in the SocketX.tlh file.
is there any help with the statement  __uuidof(ISocketXObj) ???
how can I use my dll and its methods in my application.
Can anyone suggest me some help
0
Comment
Question by:geethaes
4 Comments
 
LVL 9

Accepted Solution

by:
_ys_ earned 25 total points
ID: 9625891
>> CLSIDFromProgID(OLESTR("SocketXObjLib.ISocketXObj"), &clsid);
Not quite what you're looking for. This will nearly always fail.
The ProgId is typcially structered as "{library_name}.{component_name}". For you  example this will probably be "SocketXObjLib.CSocketXObj".


Saying that you can get around all of this, but reusing the generated files directly.

If you add
#import "SocketX.dll" named_guids no_namespace
to your compilation module you should then be able to do

CoCreateInstance (CLSID_CSocketXObj, 0 CLSCTX_SERVER, IID_ISocketXObj, reinterpret_cast<void**>(&t));

directly, without using CLSIDFromProgID or __uuidof.
0
 
LVL 2

Expert Comment

by:carribus
ID: 9626018
to add to the above post from _ys_,

1. Make sure you have called ::CoInitialise(NULL) before you do anything else (remember to call ::CoUninitialise())
2. Are you sure the ProgID you are requesting is valid. Just do a quick search for it in your registry. If its not there, you might need to register the dll (alternatively, if the ProgID is wrong, you will need to find the correct ProgID).

Take care
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10546175
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: _ys_ {http:#9625891}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

777 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