home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / mts4.cab / Account.VC_Account.cpp < prev    next >
C/C++ Source or Header  |  1997-11-14  |  4KB  |  134 lines

  1. // Filename: Account.cpp
  2. //
  3. // Description: Implementation of DLL Exports.
  4. //
  5. // This file is provided as part of the Microsoft Transaction Server Samples
  6. //
  7. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT 
  8. // WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, 
  9. // INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
  10. // OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR 
  11. // PURPOSE.
  12. //
  13. // Copyright (C) 1997 Microsoft Corporation, All rights reserved
  14. //
  15. //
  16. // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this 
  17. // project.  This is because you will need MIDL 3.00.15 or higher and new
  18. // headers and libs.  If you have VC 4.2 installed, then everything should
  19. // already be configured correctly.
  20.  
  21. // Note: Proxy/Stub Information
  22. //        To merge the proxy/stub code into the object DLL, add the file 
  23. //        dlldatax.c to the project.  Make sure precompiled headers 
  24. //        are turned off for this file, and add _MERGE_PROXYSTUB to the 
  25. //        defines for the project.  
  26. //
  27. //        Modify the custom build rule for Account.idl by adding the following 
  28. //        files to the Outputs.  You can select all of the .IDL files by 
  29. //        expanding each project and holding Ctrl while clicking on each of them.
  30. //            Account_p.c
  31. //            dlldata.c
  32. //        To build a separate proxy/stub DLL,
  33. //        run nmake -f Accountps.mak in the project directory.
  34.  
  35. #include "stdafx.h"
  36. #include "resource.h"
  37. #include "initguid.h"
  38. #include "Account.h"
  39. #include "CAccount.h"
  40. #include "MoveMoney.h"
  41. //
  42. // to merge proxy/stub, uncomment this line
  43. // #include "dlldatax.h"
  44. //
  45. #define IID_DEFINED
  46. #include "Account_i.c"
  47. #include "GetReceipt.h"
  48. #include "UpdateReceipt.h"
  49.  
  50. #ifdef _MERGE_PROXYSTUB
  51. extern "C" HINSTANCE hProxyDll;
  52. #endif
  53.  
  54. CComModule _Module;
  55.  
  56. BEGIN_OBJECT_MAP(ObjectMap)
  57.     OBJECT_ENTRY(CLSID_CUpdateReceipt, CUpdateReceipt)
  58.     OBJECT_ENTRY(CLSID_CGetReceipt, CGetReceipt)
  59.     OBJECT_ENTRY(CLSID_CAccount, CAccount)
  60.     OBJECT_ENTRY(CLSID_CMoveMoney, CMoveMoney)
  61. END_OBJECT_MAP()
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // DLL Entry Point
  65.  
  66. extern "C"
  67. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  68. {
  69.     lpReserved;
  70. #ifdef _MERGE_PROXYSTUB
  71.     if (!PrxDllMain(hInstance, dwReason, lpReserved))
  72.         return FALSE;
  73. #endif
  74.     if (dwReason == DLL_PROCESS_ATTACH)
  75.     {
  76.         _Module.Init(ObjectMap, hInstance);
  77.         DisableThreadLibraryCalls(hInstance);
  78.     }
  79.     else if (dwReason == DLL_PROCESS_DETACH)
  80.         _Module.Term();
  81.     return TRUE;    // ok
  82. }
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // Used to determine whether the DLL can be unloaded by OLE
  86.  
  87. STDAPI DllCanUnloadNow(void)
  88. {
  89. #ifdef _MERGE_PROXYSTUB
  90.     if (PrxDllCanUnloadNow() != S_OK)
  91.         return S_FALSE;
  92. #endif
  93.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  94. }
  95.  
  96. /////////////////////////////////////////////////////////////////////////////
  97. // Returns a class factory to create an object of the requested type
  98.  
  99. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  100. {
  101. #ifdef _MERGE_PROXYSTUB
  102.     if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  103.         return S_OK;
  104. #endif
  105.     return _Module.GetClassObject(rclsid, riid, ppv);
  106. }
  107.  
  108. /////////////////////////////////////////////////////////////////////////////
  109. // DllRegisterServer - Adds entries to the system registry
  110.  
  111. STDAPI DllRegisterServer(void)
  112. {
  113. #ifdef _MERGE_PROXYSTUB
  114.     HRESULT hRes = PrxDllRegisterServer();
  115.     if (FAILED(hRes))
  116.         return hRes;
  117. #endif
  118.     // registers object, typelib and all interfaces in typelib
  119.     return _Module.RegisterServer(TRUE);
  120. }
  121.  
  122. /////////////////////////////////////////////////////////////////////////////
  123. // DllUnregisterServer - Removes entries from the system registry
  124.  
  125. STDAPI DllUnregisterServer(void)
  126. {
  127. #ifdef _MERGE_PROXYSTUB
  128.     PrxDllUnregisterServer();
  129. #endif
  130.     _Module.UnregisterServer();
  131.     return S_OK;
  132. }
  133.  
  134.