home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / licserve / licserve.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-30  |  18.4 KB  |  566 lines

  1. /*+==========================================================================
  2.   File:      LICSERVE.CPP
  3.  
  4.   Summary:   Implementation file for a DLL COM Component server providing
  5.              the licensed COM component COLicCruiseCar. This server
  6.              supports self registration and unregistration.  A special
  7.              Utility COM Component is also provided: COLicCarSample.
  8.              Exposing an ISample interface it supports utility operations
  9.              on the DLL server itself (eg, the server can be given a
  10.              pointer to the Client's trace Logging facility and can be
  11.              told to show the server's Aboutbox dialog).
  12.  
  13.              For a comprehensive tutorial code tour of LICSERVE's contents
  14.              and offerings see the tutorial LICSERVE.HTM file. For
  15.              more specific technical details on the internal workings see
  16.              the comments dispersed throughout the LICSERVE source code.
  17.  
  18.   Classes:   none.
  19.  
  20.   Functions: DllMain, DllGetClassObject, DllCanUnloadNow, DllRegisterServer,
  21.              DllUnregisterServer.
  22.  
  23.   Origin:    10-5-95: atrent - Editor-inheritance from DLLSERVE.CPP in
  24.                the DLLSERVE Tutorial Code Sample.
  25.  
  26. ----------------------------------------------------------------------------
  27.   This file is part of the Microsoft COM Tutorial Code Samples.
  28.  
  29.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  30.  
  31.   This source code is intended only as a supplement to Microsoft
  32.   Development Tools and/or on-line documentation.  See these other
  33.   materials for detailed information regarding Microsoft code samples.
  34.  
  35.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  36.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  37.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  38.   PARTICULAR PURPOSE.
  39. ==========================================================================+*/
  40.  
  41. /*---------------------------------------------------------------------------
  42.   We include WINDOWS.H for all Win32 applications.
  43.   We include OLE2.H because we will be calling the COM/OLE Libraries.
  44.   We include INITGUID.H only once (here) in the entire DLL because we
  45.     will be defining GUIDs and want them as constants in the data segment.
  46.   We include OLECTL.H because we will using IClassFactory2.
  47.   We include APPUTIL.H because we will be building this DLL using
  48.     the convenient Virtual Window and Dialog classes and other
  49.     utility functions in the APPUTIL Library (ie, APPUTIL.LIB).
  50.   We include ICARS.H and CARGUIDS.H for the common car-related Interface
  51.     class, GUID, and CLSID specifications.
  52.   We include LICSERVE.H because it has the main declerations of all the
  53.     car related interfaces and their GUIDs.  It also has the _DLLEXPORT_
  54.     controlled import and export specifications.
  55.   We include SERVER.H because it has the necessary internal class and
  56.     resource definitions for this DLL.
  57.   We include FACTORY.H because it has the necessary internal class factory
  58.     declarations for this DLL component server.
  59. ---------------------------------------------------------------------------*/
  60. #include <windows.h>
  61. #include <ole2.h>
  62. #include <initguid.h>
  63. #include <olectl.h>
  64. #include <apputil.h>
  65. #include <icars.h>
  66. #include <carguids.h>
  67. #define _DLLEXPORT_
  68. #include "licserve.h"
  69. #include "server.h"
  70. #include "factory.h"
  71.  
  72.  
  73. // Global variable definitions. Some Initialized in DllMain() below.
  74.  
  75. // We encapsulate the control of this COM server (eg, lock and object
  76. // counting) in a server control C++ object.  Here is it's pointer.
  77. CServer* g_pServer = NULL;
  78.  
  79. // Here is a pointer for use by the global Trace Message logging macros.
  80. // Set by the ISample::Init function call from an outside EXE client.
  81. CMsgLog* g_pMsgLog = NULL;
  82.  
  83.  
  84. /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  85.   Function: UnicodeOk
  86.  
  87.   Summary:  Checks if the platform will handle unicode versions of
  88.             Win32 string API calls.
  89.  
  90.   Args:     void
  91.  
  92.   Returns:  BOOL
  93.               TRUE if unicode support; FALSE if not.
  94. ------------------------------------------------------------------------F-F*/
  95. BOOL UnicodeOk(void)
  96. {
  97.   BOOL bOk = TRUE;
  98.   TCHAR szUserName[MAX_STRING_LENGTH];
  99.   DWORD dwSize = MAX_STRING_LENGTH;
  100.  
  101.   if (!GetUserName(szUserName, &dwSize))
  102.     bOk = ERROR_CALL_NOT_IMPLEMENTED == GetLastError() ? FALSE : TRUE;
  103.  
  104.   return bOk;
  105. }
  106.  
  107.  
  108. /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
  109.   Function: DllMain
  110.  
  111.   Summary:  Like WinMain is for an EXE application, this DllMain function
  112.             is the main entry point for this DLL.  It is called when the
  113.             DLL is loaded by a process, and when new threads are created
  114.             by a process that has already loaded this DLL.  DllMain is also
  115.             called when threads of a process that has loaded the DLL exit
  116.             cleanly and when the process itself unloads the DLL.
  117.  
  118.             If you want to use C runtime libraries, keep this function
  119.             named "DllMain" and you won't have to do anything special to
  120.             initialize the runtime libraries.
  121.  
  122.             When fdwReason == DLL_PROCESS_ATTACH, the return value is used
  123.             to determine if the DLL should remain loaded, or should be
  124.             immediately unloaded depending upon whether the DLL could be
  125.             initialized properly.  For all other values of fdwReason,
  126.             the return value is ignored.
  127.  
  128.   Args:     HINSTANCE hDLLInst,
  129.               Instance handle of the DLL.
  130.             DWORD fdwReason,
  131.               Process attach/detach or thread attach/detach.
  132.               Reason for calling.
  133.             LPVOID lpvReserved)
  134.               Reserved and not used.
  135.  
  136.   Returns:  BOOL,
  137.               Return value is used only when fdwReason == DLL_PROCESS_ATTACH.
  138.               TRUE  -  Used to signify that the DLL should remain loaded.
  139.               FALSE -  Used to signify that the DLL should be
  140.                 immediately unloaded.
  141. F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
  142. BOOL WINAPI DllMain(
  143.               HINSTANCE hDllInst,
  144.               DWORD fdwReason,
  145.               LPVOID lpvReserved)
  146. {
  147.   BOOL bResult = TRUE;
  148.  
  149.   // Dispatch this main call based on the reason it was called.
  150.   switch (fdwReason)
  151.   {
  152.     case DLL_PROCESS_ATTACH:
  153.       // The DLL is being loaded for the first time by a given process.
  154.       // Perform per-process initialization here.  If the initialization
  155.       // is successful, return TRUE; if unsuccessful, return FALSE.
  156.       bResult = FALSE;
  157.       if (UnicodeOk())
  158.       {
  159.         // Instantiate the CServer utility class.
  160.         g_pServer = new CServer;
  161.         if (NULL != g_pServer)
  162.         {
  163.           // Remember the DLL Instance handle.
  164.           g_pServer->m_hDllInst = hDllInst;
  165.  
  166.           // Create a MsgBox object.
  167.           g_pServer->m_pMsgBox = new CMsgBox;
  168.           if (NULL != g_pServer->m_pMsgBox)
  169.           {
  170.             // Check for valid Machine License.
  171.             g_pServer->CheckLicense();
  172.             bResult = TRUE;
  173.           }
  174.         }
  175.       }
  176.       break;
  177.  
  178.     case DLL_PROCESS_DETACH:
  179.       // The DLL is being unloaded by a given process.  Do any
  180.       // per-process clean up here, such as undoing what was done in
  181.       // DLL_PROCESS_ATTACH.  The return value is ignored.
  182.       DELETE_POINTER(g_pServer->m_pMsgBox);
  183.       DELETE_POINTER(g_pServer);
  184.       break;
  185.  
  186.     case DLL_THREAD_ATTACH:
  187.       // A thread is being created in a process that has already loaded
  188.       // this DLL.  Perform any per-thread initialization here.  The
  189.       // return value is ignored.
  190.       break;
  191.  
  192.     case DLL_THREAD_DETACH:
  193.       // A thread is exiting cleanly in a process that has already
  194.       // loaded this DLL.  Perform any per-thread clean up here.  The
  195.       // return value is ignored.
  196.       break;
  197.  
  198.     default:
  199.       break;
  200.   }
  201.  
  202.   return (bResult);
  203. }
  204.  
  205.  
  206. /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
  207.   Function: DllGetClassObject
  208.  
  209.   Summary:  The standard exported function that the COM service library
  210.             uses to obtain an object class of the class factory for a
  211.             specified component provided by this server DLL.
  212.  
  213.   Args:     REFCLSID rclsid,
  214.               [in] The CLSID of the requested Component.
  215.             REFIID riid,
  216.               [in] GUID of the requested interface on the Class Factory.
  217.             PPVOID ppv)
  218.               [out] Address of the caller's pointer variable that will
  219.               receive the requested interface pointer.
  220.  
  221.   Returns:  HRESULT
  222.               E_FAIL if requested component isn't supported.
  223.               E_OUTOFMEMORY if out of memory.
  224.               Error code out of the QueryInterface.
  225. F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
  226. STDAPI DllGetClassObject(
  227.          REFCLSID rclsid,
  228.          REFIID riid,
  229.          PPVOID ppv)
  230. {
  231.   HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
  232.   IUnknown* pCob = NULL;
  233.  
  234.   if (CLSID_LicCruiseCar == rclsid)
  235.   {
  236.     LOG("P: DllGetClassObject: Requesting CFLicCruiseCar.");
  237.     hr = E_OUTOFMEMORY;
  238.     pCob = new CFLicCruiseCar(NULL, g_pServer);
  239.   }
  240.   else if (CLSID_LicCarSample == rclsid)
  241.   {
  242.     LOG("P: DllGetClassObject: Requesting CFLicCarSample.");
  243.     hr = E_OUTOFMEMORY;
  244.     pCob = new CFLicCarSample(NULL, g_pServer);
  245.   }
  246.  
  247.   if (NULL != pCob)
  248.   {
  249.     g_pServer->ObjectsUp();
  250.     hr = pCob->QueryInterface(riid, ppv);
  251.     if (FAILED(hr))
  252.     {
  253.       g_pServer->ObjectsDown();
  254.       DELETE_POINTER(pCob);
  255.     }
  256.   }
  257.  
  258.   return hr;
  259. }
  260.  
  261.  
  262. /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
  263.   Function: DllCanUnloadNow
  264.  
  265.   Summary:  The standard exported function that the COM service library
  266.             uses to determine if this server DLL can be unloaded.
  267.  
  268.   Args:     void.
  269.  
  270.   Returns:  HRESULT
  271.               S_OK if this DLL server can be unloaded.
  272.               S_FALSE if this DLL can not be unloaded.
  273. F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
  274. STDAPI DllCanUnloadNow(void)
  275. {
  276.   HRESULT hr;
  277.  
  278.   LOGF2("P: DllCanUnloadNow. cObjects=%i, cLocks=%i.", g_pServer->m_cObjects, g_pServer->m_cLocks);
  279.  
  280.   // We return S_OK of there are no longer any living objects AND
  281.   // there are no outstanding client locks on this server.
  282.   hr = (0L==g_pServer->m_cObjects && 0L==g_pServer->m_cLocks) ? S_OK : S_FALSE;
  283.  
  284.   return hr;
  285. }
  286.  
  287.  
  288. /*F+F++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  289.   Function: SetRegKeyValue
  290.  
  291.   Summary:  Internal utility function to set a Key, Subkey, and value
  292.             in the system Registry under HKEY_CLASSES_ROOT.
  293.  
  294.   Args:     LPTSTR pszKey,
  295.             LPTSTR pszSubkey,
  296.             LPTSTR pszValue)
  297.  
  298.   Returns:  BOOL
  299.               TRUE if success; FALSE if not.
  300. ------------------------------------------------------------------------F-F*/
  301. BOOL SetRegKeyValue(
  302.        LPTSTR pszKey,
  303.        LPTSTR pszSubkey,
  304.        LPTSTR pszValue)
  305. {
  306.   BOOL bOk = FALSE;
  307.   LONG ec;
  308.   HKEY hKey;
  309.   TCHAR szKey[MAX_STRING_LENGTH];
  310.  
  311.   lstrcpy(szKey, pszKey);
  312.  
  313.   if (NULL != pszSubkey)
  314.   {
  315.     lstrcat(szKey, TEXT("\\"));
  316.     lstrcat(szKey, pszSubkey);
  317.   }
  318.  
  319.   ec = RegCreateKeyEx(
  320.          HKEY_CLASSES_ROOT,
  321.          szKey,
  322.          0,
  323.          NULL,
  324.          REG_OPTION_NON_VOLATILE,
  325.          KEY_ALL_ACCESS,
  326.          NULL,
  327.          &hKey,
  328.          NULL);
  329.  
  330.   if (ERROR_SUCCESS == ec)
  331.   {
  332.     if (NULL != pszValue)
  333.     {
  334.       ec = RegSetValueEx(
  335.              hKey,
  336.              NULL,
  337.              0,
  338.              REG_SZ,
  339.              (BYTE *)pszValue,
  340.              (lstrlen(pszValue)+1)*sizeof(TCHAR));
  341.     }
  342.     if (ERROR_SUCCESS == ec)
  343.       bOk = TRUE;
  344.     RegCloseKey(hKey);
  345.   }
  346.  
  347.   return bOk;
  348. }
  349.  
  350.  
  351. /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
  352.   Function: DllRegisterServer
  353.  
  354.   Summary:  The standard exported function that can be called to command
  355.             this DLL server to register itself in the system registry.
  356.  
  357.   Args:     void.
  358.  
  359.   Returns:  HRESULT
  360.               NOERROR
  361. F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
  362. STDAPI DllRegisterServer(void)
  363. {
  364.   HRESULT  hr = NOERROR;
  365.   TCHAR    szID[GUID_SIZE+1];
  366.   TCHAR    szCLSID[GUID_SIZE+32];
  367.   TCHAR    szModulePath[MAX_PATH];
  368.  
  369.   // Obtain the path to this module's executable file for later use.
  370.   GetModuleFileName(
  371.     g_pServer->m_hDllInst,
  372.     szModulePath,
  373.     sizeof(szModulePath) / sizeof(TCHAR));
  374.  
  375.   /*-------------------------------------------------------------------------
  376.     Create registry entries for the LicCruiseCar Component.
  377.   -------------------------------------------------------------------------*/
  378.   // Create some base key strings.
  379.   StringFromGUID2(CLSID_LicCruiseCar, szID, GUID_SIZE);
  380.   lstrcpy(szCLSID, TEXT("CLSID\\"));
  381.   lstrcat(szCLSID, szID);
  382.  
  383.   // Create ProgID keys.
  384.   SetRegKeyValue(
  385.     TEXT("CTS.LicCruiseCar.1"),
  386.     NULL,
  387.     TEXT("LicCruiseCar Component - LICSERVE Code Sample"));
  388.   SetRegKeyValue(
  389.     TEXT("CTS.LicCruiseCar.1"),
  390.     TEXT("CLSID"),
  391.     szID);
  392.  
  393.   // Create VersionIndependentProgID keys.
  394.   SetRegKeyValue(
  395.     TEXT("CTS.LicCruiseCar"),
  396.     NULL,
  397.     TEXT("LicCruiseCar Component - LICSERVE Code Sample"));
  398.   SetRegKeyValue(
  399.     TEXT("CTS.LicCruiseCar"),
  400.     TEXT("CurVer"),
  401.     TEXT("CTS.LicCruiseCar.1"));
  402.   SetRegKeyValue(
  403.     TEXT("CTS.LicCruiseCar"),
  404.     TEXT("CLSID"),
  405.     szID);
  406.  
  407.   // Create entries under CLSID.
  408.   SetRegKeyValue(
  409.     szCLSID,
  410.     NULL,
  411.     TEXT("LicCruiseCar Component - LICSERVE Code Sample"));
  412.   SetRegKeyValue(
  413.     szCLSID,
  414.     TEXT("ProgID"),
  415.     TEXT("CTS.LicCruiseCar.1"));
  416.   SetRegKeyValue(
  417.     szCLSID,
  418.     TEXT("VersionIndependentProgID"),
  419.     TEXT("CTS.LicCruiseCar"));
  420.   SetRegKeyValue(
  421.     szCLSID,
  422.     TEXT("NotInsertable"),
  423.     NULL);
  424.   SetRegKeyValue(
  425.     szCLSID,
  426.     TEXT("InprocServer32"),
  427.     szModulePath);
  428.  
  429.   /*-------------------------------------------------------------------------
  430.     Create registry entries for the LicCarSample Component.
  431.   -------------------------------------------------------------------------*/
  432.   // Create some base key strings.
  433.   StringFromGUID2(CLSID_LicCarSample, szID, GUID_SIZE);
  434.   lstrcpy(szCLSID, TEXT("CLSID\\"));
  435.   lstrcat(szCLSID, szID);
  436.  
  437.   // Create ProgID keys.
  438.   SetRegKeyValue(
  439.     TEXT("CTS.LicCarSample.1"),
  440.     NULL,
  441.     TEXT("LicCarSample Component - LICSERVE Code Sample"));
  442.   SetRegKeyValue(
  443.     TEXT("CTS.LicCarSample.1"),
  444.     TEXT("CLSID"),
  445.     szID);
  446.  
  447.   // Create VersionIndependentProgID keys.
  448.   SetRegKeyValue(
  449.     TEXT("CTS.LicCarSample"),
  450.     NULL,
  451.     TEXT("LicCarSample Component - LICSERVE Code Sample"));
  452.   SetRegKeyValue(
  453.     TEXT("CTS.LicCarSample"),
  454.     TEXT("CurVer"),
  455.     TEXT("CTS.LicCarSample.1"));
  456.   SetRegKeyValue(
  457.     TEXT("CTS.LicCarSample"),
  458.     TEXT("CLSID"),
  459.     szID);
  460.  
  461.   // Create entries under CLSID.
  462.   SetRegKeyValue(
  463.     szCLSID,
  464.     NULL,
  465.     TEXT("LicCarSample Component - LICSERVE Code Sample"));
  466.   SetRegKeyValue(
  467.     szCLSID,
  468.     TEXT("ProgID"),
  469.     TEXT("CTS.LicCarSample.1"));
  470.   SetRegKeyValue(
  471.     szCLSID,
  472.     TEXT("VersionIndependentProgID"),
  473.     TEXT("CTS.LicCarSample"));
  474.   SetRegKeyValue(
  475.     szCLSID,
  476.     TEXT("NotInsertable"),
  477.     NULL);
  478.   SetRegKeyValue(
  479.     szCLSID,
  480.     TEXT("InprocServer32"),
  481.     szModulePath);
  482.  
  483.   return hr;
  484. }
  485.  
  486.  
  487. /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F
  488.   Function: DllUnregisterServer
  489.  
  490.   Summary:  The standard exported function that can be called to command
  491.             this DLL server to unregister itself from the system Registry
  492.             (under main key: HKEY_CLASSES_ROOT).
  493.  
  494.   Args:     void.
  495.  
  496.   Returns:  HRESULT
  497.               NOERROR
  498. F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/
  499. STDAPI DllUnregisterServer(void)
  500. {
  501.   HRESULT  hr = NOERROR;
  502.   TCHAR    szID[GUID_SIZE+1];
  503.   TCHAR    szCLSID[GUID_SIZE+32];
  504.   TCHAR    szTemp[MAX_PATH+GUID_SIZE];
  505.  
  506.   /*-------------------------------------------------------------------------
  507.     Delete registry entries for the LicCruiseCar Component.
  508.   -------------------------------------------------------------------------*/
  509.   //Create some base key strings.
  510.   StringFromGUID2(CLSID_LicCruiseCar, szID, GUID_SIZE);
  511.   lstrcpy(szCLSID, TEXT("CLSID\\"));
  512.   lstrcat(szCLSID, szID);
  513.  
  514.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCruiseCar\\CurVer"));
  515.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCruiseCar\\CLSID"));
  516.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCruiseCar"));
  517.  
  518.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCruiseCar.1\\CLSID"));
  519.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCruiseCar.1"));
  520.  
  521.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
  522.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  523.  
  524.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
  525.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  526.  
  527.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
  528.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  529.  
  530.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
  531.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  532.  
  533.   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
  534.  
  535.   /*-------------------------------------------------------------------------
  536.     Delete registry entries for the LicCarSample Component.
  537.   -------------------------------------------------------------------------*/
  538.   //Create some base key strings.
  539.   StringFromGUID2(CLSID_LicCarSample, szID, GUID_SIZE);
  540.   lstrcpy(szCLSID, TEXT("CLSID\\"));
  541.   lstrcat(szCLSID, szID);
  542.  
  543.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCarSample\\CurVer"));
  544.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCarSample\\CLSID"));
  545.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCarSample"));
  546.  
  547.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCarSample.1\\CLSID"));
  548.   RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CTS.LicCarSample.1"));
  549.  
  550.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("ProgID"));
  551.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  552.  
  553.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("VersionIndependentProgID"));
  554.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  555.  
  556.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("NotInsertable"));
  557.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  558.  
  559.   wsprintf(szTemp, TEXT("%s\\%s"), szCLSID, TEXT("InprocServer32"));
  560.   RegDeleteKey(HKEY_CLASSES_ROOT, szTemp);
  561.  
  562.   RegDeleteKey(HKEY_CLASSES_ROOT, szCLSID);
  563.  
  564.   return hr;
  565. }
  566.