home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / source / chap03 / lst32use / lst32use.cpp next >
Encoding:
C/C++ Source or Header  |  1996-09-23  |  1.3 KB  |  60 lines

  1.  
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <olectl.h>
  5. #include <initguid.h>
  6. #include <olectlid.h>
  7.  
  8. // the class ID of the server exe
  9. // {4F126D90-1319-11d0-A6AC-00AA00602553}
  10. const CLSID CLSID_CLowerStr =
  11. {0x4f126d90, 0x1319, 0x11d0, {0xa6, 0xac, 0x0, 0xaa, 0x0, 0x60, 0x25, 0x53}};
  12.                                                                                     
  13.  // {4F126D91-1319-11d0-A6AC-00AA00602553}
  14. const CLSID IID_ILowerStr =
  15. {0x4f126d91, 0x1319, 0x11d0, {0xa6, 0xac, 0x0, 0xaa, 0x0, 0x60, 0x25, 0x53}};
  16.   
  17.  
  18. class ILowerStr: public IUnknown
  19. {
  20. public:
  21.     virtual STDMETHODIMP Lower(char* lpInput, char **lpOutput)=0;
  22. };
  23.  
  24. void __cdecl main(int argc, char *argv[])
  25. {
  26.     ILowerStr *pILowerStr = NULL;
  27.     HRESULT hr;
  28.  
  29.  
  30.     hr = CoInitialize(NULL);
  31.     if (FAILED(hr)) 
  32.     {
  33.         printf("CoInitialize failed [0x%x]\n", hr);
  34.         exit(1);
  35.     }
  36.  
  37.     hr = CoCreateInstance(CLSID_CLowerStr, 0, CLSCTX_LOCAL_SERVER,    
  38.         IID_ILowerStr,(void**)&pILowerStr);
  39.  
  40.     if (FAILED(hr)) 
  41.     {
  42.         printf("CoCreateInstance failed [0x%x]\n", hr);
  43.         if (hr == REGDB_E_CLASSNOTREG) 
  44.         {
  45.             printf("Run lst32.exe /REGSERVER to install server program.\n");
  46.         }
  47.         exit(1);
  48.     }
  49.  
  50.     char *lpOutput;
  51.  
  52.     pILowerStr->Lower("HELLO", &lpOutput);
  53.  
  54.     printf("this is it %s\n", lpOutput);
  55.  
  56.     pILowerStr->Release();
  57.     CoUninitialize();
  58. }
  59.  
  60.