I am trying to implement the COM method of DllRegisterServer.
So I read this lesson:
http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567/Step-by-Step-COM-Tutorial.htm
and I followed the steps to the DllRegisterServer part.
This is their implementation:
HRESULT __stdcall DllRegisterServer(void) { // //As per COM guidelines, every self installable COM inprocess component //should export the function DllRegisterServer for printing the //specified information to the registry // // WCHAR *lpwszClsid; char szBuff[MAX_PATH]=""; char szClsid[MAX_PATH]="", szInproc[MAX_PATH]="",szProgId[MAX_PATH]; char szDescriptionVal[256]=""; StringFromCLSID( CLSID_AddObject, &lpwszClsid); wsprintf(szClsid,"%S",lpwszClsid); wsprintf(szInproc,"%s\\%s\\%s","clsid",szClsid,"InprocServer32"); wsprintf(szProgId,"%s\\%s\\%s","clsid",szClsid,"ProgId"); // //write the default value // wsprintf(szBuff,"%s","Fast Addition Algorithm"); wsprintf(szDescriptionVal,"%s\\%s","clsid",szClsid); HelperWriteKey ( HKEY_CLASSES_ROOT, szDescriptionVal, NULL,//write to the "default" value REG_SZ, (void*)szBuff, lstrlen(szBuff) ); // //write the "InprocServer32" key data // GetModuleFileName( g_hModule, szBuff, sizeof(szBuff)); HelperWriteKey ( HKEY_CLASSES_ROOT, szInproc, NULL,//write to the "default" value REG_SZ, (void*)szBuff, lstrlen(szBuff) ); // //write the "ProgId" key data under HKCR\clsid\{---}\ProgId // lstrcpy(szBuff,AddObjProgId); HelperWriteKey ( HKEY_CLASSES_ROOT, szProgId, NULL, REG_SZ, (void*)szBuff, lstrlen(szBuff) ); // //write the "ProgId" data under HKCR\CodeGuru.FastAddition // wsprintf(szBuff,"%s","Fast Addition Algorithm"); HelperWriteKey ( HKEY_CLASSES_ROOT, AddObjProgId, NULL, REG_SZ, (void*)szBuff, lstrlen(szBuff) ); wsprintf(szProgId,"%s\\%s",AddObjProgId,"CLSID"); HelperWriteKey ( HKEY_CLASSES_ROOT, szProgId, NULL, REG_SZ, (void*)szClsid, lstrlen(szClsid) ); return 1; }
where CLSID_AddObject is defined as follows:
I do not understand: 1. Why do they use StringFromCLSID to get the GUID as a string? Do they already have this, and for some reason do they convert it to IID? is this not the GUID that we give in the IDL file well enough?
2. What GUIDs should be registered? The GUID of the library? GUID of interfaces? GUID classes? or all of them?