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.

173 lines
4.0 KiB

  1. /*****************************************************************************\
  2. * MODULE: dllmain.cpp
  3. *
  4. * PURPOSE: Implementation of COM interface for BidiSpooler
  5. *
  6. * Copyright (C) 2000 Microsoft Corporation
  7. *
  8. * History:
  9. *
  10. * 03/07/00 Weihai Chen (weihaic) Created
  11. *
  12. \*****************************************************************************/
  13. #include "precomp.h"
  14. #include "priv.h"
  15. extern "C" {
  16. #ifdef DEBUG
  17. MODULE_DEBUG_INIT( DBG_ERROR | DBG_WARNING | DBG_TRACE | DBG_INFO , DBG_ERROR );
  18. #else
  19. MODULE_DEBUG_INIT( DBG_ERROR , DBG_ERROR );
  20. #endif
  21. }
  22. ///////////////////////////////////////////////////////////
  23. //
  24. // Global variables
  25. //
  26. static HMODULE g_hModule = NULL ; // DLL module handle
  27. const TCHAR g_szFriendlyName[] = _T ("Bidi Spooler APIs") ;
  28. const TCHAR g_szRequestVerIndProgID[] = _T ("bidispl.bidirequest") ;
  29. const TCHAR g_szRequestProgID[] = _T ("bidispl.bidirequest.1") ;
  30. const TCHAR g_szContainerVerIndProgID[] = _T ("bidispl.bidirequestcontainer") ;
  31. const TCHAR g_szContainerProgID[] = _T ("bidispl.bidirequestcontainer.1") ;
  32. const TCHAR g_szSplVerIndProgID[] = _T ("bidispl.bidispl") ;
  33. const TCHAR g_szSplProgID[] = _T ("bidispl.bidispl.1") ;
  34. ///////////////////////////////////////////////////////////
  35. //
  36. // Exported functions
  37. //
  38. //
  39. // Can DLL unload now?
  40. //
  41. STDAPI DllCanUnloadNow()
  42. {
  43. if ((g_cComponents == 0) && (g_cServerLocks == 0))
  44. {
  45. return S_OK ;
  46. }
  47. else
  48. {
  49. return S_FALSE ;
  50. }
  51. }
  52. //
  53. // Get class factory
  54. //
  55. STDAPI DllGetClassObject(REFCLSID clsid,
  56. REFIID iid,
  57. PVOID * ppv)
  58. {
  59. DBGMSG(DBG_TRACE,("Enter DllGetClassObject\n"));
  60. // Can we create this component?
  61. if (clsid != CLSID_BidiRequest &&
  62. clsid != CLSID_BidiRequestContainer &&
  63. clsid != CLSID_BidiSpl) {
  64. return CLASS_E_CLASSNOTAVAILABLE ;
  65. }
  66. // Create class factory.
  67. TFactory* pFactory = new TFactory (clsid) ; // Reference count set to 1
  68. // in constructor
  69. if (pFactory == NULL)
  70. {
  71. return E_OUTOFMEMORY ;
  72. }
  73. // Get requested interface.
  74. HRESULT hr = pFactory->QueryInterface(iid, ppv) ;
  75. pFactory->Release() ;
  76. return hr ;
  77. }
  78. //
  79. // Server registration
  80. //
  81. STDAPI DllRegisterServer()
  82. {
  83. BOOL bRet;
  84. TComRegistry ComReg;
  85. bRet = ComReg.RegisterServer(g_hModule,
  86. CLSID_BidiRequest,
  87. g_szFriendlyName,
  88. g_szRequestProgID,
  89. g_szRequestProgID) &&
  90. ComReg.RegisterServer (g_hModule,
  91. CLSID_BidiRequestContainer,
  92. g_szFriendlyName,
  93. g_szContainerVerIndProgID,
  94. g_szContainerProgID) &&
  95. ComReg.RegisterServer(g_hModule,
  96. CLSID_BidiSpl,
  97. g_szFriendlyName,
  98. g_szSplVerIndProgID,
  99. g_szSplProgID);
  100. return bRet;
  101. }
  102. //
  103. // Server unregistration
  104. //
  105. STDAPI DllUnregisterServer()
  106. {
  107. TComRegistry ComReg;
  108. return ComReg.UnregisterServer(CLSID_BidiRequest,
  109. g_szRequestVerIndProgID,
  110. g_szRequestProgID) &&
  111. ComReg.UnregisterServer(CLSID_BidiRequestContainer,
  112. g_szContainerVerIndProgID,
  113. g_szContainerProgID) &&
  114. ComReg.UnregisterServer(CLSID_BidiSpl,
  115. g_szSplVerIndProgID,
  116. g_szSplProgID);
  117. }
  118. ///////////////////////////////////////////////////////////
  119. //
  120. // DLL module information
  121. //
  122. BOOL APIENTRY DllMain(HANDLE hModule,
  123. DWORD dwReason,
  124. void* lpReserved)
  125. {
  126. if (dwReason == DLL_PROCESS_ATTACH)
  127. {
  128. g_hModule = hModule ;
  129. //if( !bSplLibInit( NULL )){
  130. //
  131. // DBGMSG( DBG_WARN,
  132. // ( "DllEntryPoint: Failed to init SplLib %d\n", GetLastError()));
  133. //}
  134. }
  135. return TRUE ;
  136. }