In VC++, I have to hardcoded the .net dll's ClassId if i want to create the com instance. How can i get the .net COM's classID without having to create the instance first ?
---------------------------------------
#import "Sample.tlb"
using namespace Sample;
//******NOTE******
const IID CLSID_SampleObj = {0x5B85B3EB,0x899B,0x440f, {0xBF,0x0A,0x67,0x43,0x0B,0x7A,0x17,0x1F}};
int main(int argc, char* argv[])
{
HRESULT hr;
CoInitialize(NULL);
CComPtr<SampleObj> Obj = NULL;
hr = Obj.CoCreateInstance(CLSID_SampleObj, NULL, CLSCTX_ALL);
string tooLateToGetClsidHere = Obj->GetCLSID();
}
------------------------------------------------------------------------------
Phil Wilson - 16 Jul 2004 15:49 GMT
This is a confusing question - the entire COM client-server model is based
on the client knowing the clsid before calling the COM server (or knowing a
ProgId, which amounts to the same thing). How could you *not* know the clsid
of your object? Would a ProgId solve your problem? That import will generate
a header file that will have some Guids in it - is that what you're looking
for?

Signature
Phil Wilson
[MVP Windows Installer]
> In VC++, I have to hardcoded the .net dll's ClassId if i want to create the com instance. How can i get the .net COM's classID without having to
create the instance first ?
> ---------------------------------------
> #import "Sample.tlb"
[quoted text clipped - 15 lines]
>
> ------------------------------------------------------------------------------
Maverick - 20 Jul 2004 05:09 GMT
thx... in fact, i was so stupid. There's no need to have the CLSID when doing CoCreateInstance of a .Net COM in VC++6 application. All i need to do is the following :
#import "C:\\MyCOMObj.tlb"
using namespace MyCOMObj;
int main()
{
HRESULT hr;
CoInitialize(NULL);
CComPtr<CSampleObj> obj = NULL;
hr = obj.CoCreateInstance(__uuidof(CSampleObj));
}
> This is a confusing question - the entire COM client-server model is based
> on the client knowing the clsid before calling the COM server (or knowing a
[quoted text clipped - 27 lines]
> > --------------------------------------------------------------------------
> ----
Naveen K Kohli - 19 Jul 2004 19:06 GMT
You can always CLSID from ProgId using ProgIDFromCLSID API.
Naveen
http://www.netomatix.com
> In VC++, I have to hardcoded the .net dll's ClassId if i want to create the com instance. How can i get the .net COM's classID without having to
create the instance first ?
> ---------------------------------------
> #import "Sample.tlb"
[quoted text clipped - 15 lines]
>
> ------------------------------------------------------------------------------