Getting CLSID for server COM in VC++

Posted on 2003-10-27
Medium Priority
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);
 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
Question by:geethaes
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

_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.

Expert Comment

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

Expert Comment

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.

EE Cleanup Volunteer

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

752 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