Solved

Getting CLSID for server COM in VC++

Posted on 2003-10-27
4
656 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

708 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

16 Experts available now in Live!

Get 1:1 Help Now