?
Solved

Getting CLSID for server COM in VC++

Posted on 2003-10-27
4
Medium Priority
?
734 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
3 Comments
 
LVL 9

Accepted Solution

by:
_ys_ earned 75 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

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!

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.
Suggested Courses

807 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