
As classes e interfaces são identificadas por GUID’s (globally unique identifiers) de 128 bits que são armazenadas no Registry.
CString strDllPath = "C:\\obcom\\debug\\obcom.dll"; // onde está a DLL
HINSTANCE h = LoadLibrary(strDllPath);
FARPROC pFunc = ::GetProcAddress((HMODULE) h, "DllRegisterServer");
(*pFunc)(); // call the function to register the server
AfxMessageBox("Server registered OK");
Na DLL:
STDAPI DllRegisterServer(void){
AFX_MANAGE_STATE(AfxGetStaticModuleState());
COleObjectFactory::UpdateRegistryAll();
return S_OK;
}
// {61B325AF-0C3B-11D2-80EC-0040333C6E0D}
static const IID IID_IOBcom =
{ 0x61b325af, 0xc3b, 0x11d2, { 0x80, 0xec, 0x0, 0x40, 0x33, 0x3c, 0x6e, 0xd } };
// {77E73490-FC71-11D1-80EC-0040333C6E0D}
IMPLEMENT_OLECREATE(COBcom, "Openbase.OBcom.1", 0x77e73490, 0xfc71, 0x11d1, 0x80, 0xec, 0x0, 0x40, 0x33, 0x3c, 0x6e, 0xd)
