Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
3.0 KiB

  1. // faxadmin.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f faxadminps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include "resource.h"
  7. #include "initguid.h"
  8. #include "faxadmin.h"
  9. #include "faxadmin_i.c"
  10. #include "FaxSnapin.h" // Fax Snapin
  11. #include "FaxSAbout.h" // Fax SnapinAbout
  12. #include "faxstrt.h"
  13. #pragma hdrstop
  14. CComModule _Module;
  15. CStringTable * GlobalStringTable;
  16. BEGIN_OBJECT_MAP(ObjectMap)
  17. OBJECT_ENTRY(CLSID_FaxSnapin, CFaxSnapin)
  18. OBJECT_ENTRY(CLSID_FaxSnapinAbout, CFaxSnapinAbout)
  19. END_OBJECT_MAP()
  20. extern "C"
  21. BOOL
  22. WINAPI
  23. DllMain(
  24. IN HINSTANCE hInstance,
  25. IN DWORD dwReason,
  26. IN LPVOID /*lpReserved*/)
  27. /*++
  28. Routine Description:
  29. DLL main.
  30. Standard ATL code.
  31. Arguments:
  32. hInstance - instance handle
  33. dwReason - DLL attach/detach/etc
  34. lpReserved - reserved
  35. Return Value:
  36. BOOL indicating failure.
  37. --*/
  38. {
  39. if(dwReason == DLL_PROCESS_ATTACH) {
  40. _Module.Init(ObjectMap, hInstance);
  41. DisableThreadLibraryCalls(hInstance);
  42. if( _Module.GetLockCount() == 0 ) {
  43. GlobalStringTable = new CStringTable(hInstance);
  44. if (!GlobalStringTable) {
  45. return FALSE;
  46. }
  47. }
  48. } else if(dwReason == DLL_PROCESS_DETACH) {
  49. _Module.Term();
  50. if( _Module.GetLockCount() == 0 ) {
  51. if(GlobalStringTable != NULL) {
  52. delete GlobalStringTable;
  53. }
  54. }
  55. }
  56. return TRUE; // ok
  57. }
  58. STDAPI
  59. DllCanUnloadNow(
  60. void)
  61. /*++
  62. Routine Description:
  63. Called to determine if the DLL is ok to unload.
  64. Standard ATL code.
  65. Arguments:
  66. None.
  67. Return Value:
  68. HRESULT S_OK to unload, S_FALSE to keep.
  69. --*/
  70. {
  71. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  72. }
  73. STDAPI
  74. DllGetClassObject(
  75. IN REFCLSID rclsid,
  76. IN REFIID riid,
  77. OUT LPVOID* ppv)
  78. /*++
  79. Routine Description:
  80. Gets the class factory.
  81. Standard ATL code.
  82. Arguments:
  83. rclsid - the clsid of the class.
  84. riid - interface id.
  85. ppv - the buffer to return the class object in.
  86. Return Value:
  87. HRESULT indicating SUCCEEDED() or FAILED()
  88. --*/
  89. {
  90. return _Module.GetClassObject(rclsid, riid, ppv);
  91. }
  92. STDAPI DllRegisterServer(void)
  93. /*++
  94. Routine Description:
  95. Registers the in-proc com server.
  96. Standard ATL code.
  97. Arguments:
  98. None.
  99. Return Value:
  100. HRESULT indicating SUCCEEDED() or FAILED()
  101. --*/
  102. {
  103. // registers object, typelib and all interfaces in typelib
  104. return _Module.RegisterServer(TRUE);
  105. }
  106. /////////////////////////////////////////////////////////////////////////////
  107. // DllUnregisterServer - Removes entries from the system registry
  108. STDAPI
  109. DllUnregisterServer(void)
  110. /*++
  111. Routine Description:
  112. UnRegisters the in-proc com server.
  113. Standard ATL code.
  114. Arguments:
  115. None.
  116. Return Value:
  117. HRESULT indicating SUCCEEDED() or FAILED()
  118. --*/
  119. {
  120. _Module.UnregisterServer();
  121. return S_OK;
  122. }