title: Implementing the DllRegisterServer method
body: <p>I'm trying to implement a COM's DllRegisterServer method.<br>
  So I read this tutorial:<br>
  <a href="http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567/Step-by-Step-COM-Tutorial.htm" rel="noreferrer">http://www.codeguru.com/cpp/com-tech/activex/tutorials/article.php/c5567/Step-by-Step-COM-Tutorial.htm</a>  </p>
  
  <p>and I followed the steps until the part of DllRegisterServer.<br>
  This is their implementation:  </p>
  
  <pre><code>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,
              &amp;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;
  
      }
  </code></pre>
  
  <p>where CLSID_AddObject is defined like this:</p>
  
  <pre><code>// {92E7A9C2-F4CB-11d4-825D-00104B3646C0}
  static const GUID CLSID_AddObject = 
  { 0x92e7a9c2, 0xf4cb, 0x11d4, { 0x82, 0x5d, 0x0, 0x10, 0x4b, 0x36, 0x46, 0xc0 } };
  </code></pre>
  
  <p>What I don't understand is:
   1. Why do they use <code>StringFromCLSID</code> to get the GUID as string? They already have it and for some reason they convert it to IID? isn't the GUID we give it in the IDL file good enough?<br>
   2. Which GUIDs need to be registered? Ther library's GUID? the interfaces' GUIDs? the classes GUIDs? or all of them?</p>