home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / source / chap04 / lst41 / lst41.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-30  |  944 b   |  60 lines

  1.  
  2. #include <objbase.h>
  3. #include "lst41c.h"
  4. #include <stdio.h>
  5.  
  6.  
  7. CLst41* g_pLst41 = NULL;
  8.  
  9. void  main()
  10. {
  11.     MSG msg;
  12.     DWORD g_dwLst41CF = 0;    
  13.     HRESULT hr;
  14.  
  15.     IClassFactory* pcf;
  16.     
  17.     if((hr = OleInitialize(NULL)) != S_OK)
  18.     {
  19.         printf("OleInitialize Failed [0x%x]\n", hr);
  20.         return;
  21.     }
  22.  
  23.     if((g_pLst41 = CLst41::Create()) == NULL)
  24.         return;
  25.  
  26.     pcf = CLst41CF::Create();
  27.     if (pcf == NULL) 
  28.         goto Clean;
  29.  
  30.     hr = CoRegisterClassObject(CLSID_CLst41,
  31.                                     pcf,
  32.                                        CLSCTX_LOCAL_SERVER,
  33.                                        REGCLS_MULTIPLEUSE,
  34.                                     &g_dwLst41CF);
  35.  
  36.     if (hr != NOERROR) 
  37.         goto Clean;
  38.     
  39.     pcf->Release();
  40.  
  41.     while(GetMessage(&msg, NULL, NULL, NULL)) 
  42.     {
  43.         TranslateMessage(&msg);
  44.         DispatchMessage(&msg);
  45.     }
  46.  
  47.  
  48. Clean:   
  49.     if(g_dwLst41CF != 0)
  50.         CoRevokeClassObject(g_dwLst41CF);
  51.  
  52.     if (g_pLst41 != NULL)
  53.         g_pLst41->Release();
  54.  
  55.     OleUninitialize();
  56. }
  57.  
  58.  
  59.  
  60.