home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / gw / oddev.exe / ODMASAMP.CPP < prev    next >
C/C++ Source or Header  |  1994-08-03  |  2KB  |  81 lines

  1. /* odmasamp.cpp - Entry point, initialization, cleanup, etc. for ODMA
  2.     sample DMS.
  3.  *
  4.  * COPYRIGHT (C) 1994
  5.  * SoftSolutions Technology Corporation
  6.  * Orem, Utah  USA
  7.  * All Rights Reserved
  8.  */
  9.  
  10. #include <windows.h>
  11. #include <memory.h>
  12. #include <compobj.h>
  13. #include <initguid.h>
  14. #include "odmacom.h"
  15. #include "odmasamp.h"
  16. #include <coguid.h>
  17.  
  18. // Globals
  19. HINSTANCE NEAR hInst;
  20. DocumentList NEAR DocList;
  21.  
  22.  
  23. #ifdef WIN32
  24. BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason,
  25.     LPVOID lpvReserved)
  26. {
  27.     hInst = hinstDLL;
  28.     return 1;
  29. }
  30.  
  31. #else
  32. int PASCAL LibMain( HINSTANCE hInstance, WORD wDataSeg, WORD cbHeapSize,
  33.     LPSTR lpCmdLine )
  34. {
  35.     /* Avoid compiler warnings about unused parameters. */
  36.     wDataSeg = wDataSeg;
  37.     cbHeapSize = cbHeapSize;
  38.     lpCmdLine = lpCmdLine;
  39.  
  40.     hInst = hInstance;
  41.  
  42.     /* Undo the lock on the data segment that was automatically
  43.        placed by the call to LocalInit() in the startup code. */
  44.     if (cbHeapSize)
  45.         UnlockData(0);
  46.  
  47.     return 1;
  48. }
  49. #endif
  50.  
  51.  
  52. /* ODMGetODMInterface - This is the main entry point for the ODMA connection
  53.    manager. */
  54. HRESULT FAR PASCAL _export ODMGetODMInterface( REFIID riid, LPVOID FAR *ppvObj,
  55.     LPUNKNOWN pUnkOuter, LPVOID pReserved, LPSTR lpszAppId, DWORD dwEnvData )
  56. {
  57.     Application *pApp;
  58.     HRESULT hRes;
  59.  
  60.     *ppvObj = NULL;        // Ensure NULL stored here in case of error return.
  61.  
  62.     // Create a new Application object.
  63.     pApp = new Application( pUnkOuter, dwEnvData );
  64.     if (pApp == NULL) {
  65.         MessageBox( (HWND)dwEnvData, "Memory allocation failure", DMSNAME, MB_OK );
  66.         return ResultFromScode( E_OUTOFMEMORY );
  67.     }
  68.  
  69.     // Get the requested interface on the application object.
  70.     hRes = pApp->GetInterface( riid, ppvObj );
  71.     if (*ppvObj)
  72.         ((LPUNKNOWN)(*ppvObj))->Release();  // Balances the ref. count from 'new'.
  73.     else
  74.         delete pApp;
  75.  
  76.     return hRes;
  77. }
  78.  
  79.  
  80.  
  81.