How to make self-registering COM server (exe) with C++ -
i'm complete beginner in com , in process of grasping ins , outs of it. right there problem i'm trying solve (it's part of test assignment).
what need make self-registering exe com server in native c++, i.e. executable register com-object on execution. of examples find tell of implementing server in dll , using regsvr32 on it, need self-registering exe.
can explain how do that?
upd: okay, little more: doesn't work. here's snippet:
int _tmain(int argc, _tchar* argv[]) { iclassfactory *factory = new isimpleserverfactory(); dword classtoken; ::coinitialize(null); coregisterclassobject( iid_isimpleserver, factory, clsctx_local_server, regcls_multipleuse, &classtoken); isimpleserver *pisimpleserver = null; hresult hr = cocreateinstance( clsid_csimpleserver, null, clsctx_local_server, iid_isimpleserver, (void **)&pisimpleserver); //<<<<<<<<<<<<<<<< fails if(succeeded(hr)) printf("instantiation successful\n"); if(pisimpleserver != null) pisimpleserver->release(); std::cin.ignore(); corevokeclassobject(classtoken); ::couninitialize(); return 0; }
the thing coregisterclassobject succeds, cocreateinstance tells me object not registered. did wrong? (i unified code same module debugging 'cause didn't work in different apps).
upd2: peter huene helped 1 - had use clsid instead of iid. works in-process. when called out-of-process (from standalone client) cocreateinstance never returns. why be?
Comments
Post a Comment