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.

153 lines
3.1 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: main.cpp
  3. //
  4. // Desc: Contains global data and DllMain.
  5. //
  6. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #include "common.hpp"
  9. HMODULE g_hModule = NULL;
  10. long g_cComponents = 0;
  11. long g_cServerLocks = 0;
  12. //exported fns
  13. //can unload?
  14. STDAPI DllCanUnloadNow()
  15. {
  16. if ((g_cComponents == 0) && (g_cServerLocks == 0))
  17. {
  18. return S_OK;
  19. }
  20. else
  21. {
  22. return S_FALSE;
  23. }
  24. }
  25. //get class factory
  26. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  27. {
  28. HRESULT hr = S_OK;
  29. //check which class it is
  30. if ((rclsid != CLSID_CDirectInputActionFramework)
  31. && (rclsid != CLSID_CDIDeviceActionConfigPage)
  32. //@@BEGIN_MSINTERNAL
  33. #ifdef DDKBUILD
  34. #ifdef DBG
  35. && (rclsid != CLSID_CDirectInputConfigUITest)
  36. #endif
  37. #endif
  38. //@@END_MSINTERNAL
  39. )
  40. {
  41. return CLASS_E_CLASSNOTAVAILABLE;
  42. }
  43. //create the appropriate class factory
  44. IClassFactory* pFact = NULL;
  45. if (rclsid == CLSID_CDirectInputActionFramework)
  46. pFact = new CFactory();
  47. if (rclsid == CLSID_CDIDeviceActionConfigPage)
  48. pFact = new CPageFactory();
  49. //@@BEGIN_MSINTERNAL
  50. #ifdef DDKBUILD
  51. #ifdef DBG
  52. if (rclsid == CLSID_CDirectInputConfigUITest)
  53. pFact = new CTestFactory();
  54. #endif
  55. #endif
  56. //@@END_MSINTERNAL
  57. if (pFact == NULL)
  58. return E_OUTOFMEMORY;
  59. hr = pFact->QueryInterface(riid, ppv);
  60. pFact->Release();
  61. return hr;
  62. }
  63. //dll module information
  64. BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
  65. {
  66. switch(dwReason)
  67. {
  68. case DLL_PROCESS_ATTACH:
  69. g_hModule = (HMODULE)hModule;
  70. CFlexWnd::RegisterWndClass((HINSTANCE)hModule);
  71. break;
  72. case DLL_PROCESS_DETACH:
  73. CFlexWnd::UnregisterWndClass((HINSTANCE)hModule);
  74. break;
  75. }
  76. return TRUE;
  77. }
  78. //server registration
  79. STDAPI DllRegisterServer()
  80. {
  81. HRESULT hr1 = S_OK, hr2 = S_OK, hr3 = S_OK;
  82. hr1 = RegisterServer(g_hModule, CLSID_CDirectInputActionFramework, _T("CLSID_CDirectInputActionFramework"), _T("DIACTFRM"), _T("DIACTFRM.1"));
  83. hr2 = RegisterServer(g_hModule, CLSID_CDIDeviceActionConfigPage, _T("CLSID_CDIDeviceActionConfigPage"), _T("DIACTFRM"), _T("DIACTFRM.1"));
  84. //@@BEGIN_MSINTERNAL
  85. #ifdef DDKBUILD
  86. #ifdef DBG
  87. hr3 = RegisterServer(g_hModule, CLSID_CDirectInputConfigUITest, _T("CLSID_CDirectInputConfigUITest"), _T("DIACTFRM"), _T("DIACTFRM.1"));
  88. #endif
  89. #endif
  90. //@@END_MSINTERNAL
  91. if (FAILED(hr1))
  92. return hr1;
  93. if (FAILED(hr2))
  94. return hr2;
  95. if (FAILED(hr3))
  96. return hr3;
  97. return S_OK;
  98. }
  99. //server unregistration
  100. STDAPI DllUnregisterServer()
  101. {
  102. HRESULT hr1 = S_OK, hr2 = S_OK, hr3 = S_OK;
  103. hr1 = UnregisterServer(CLSID_CDirectInputActionFramework, _T("DIACTFRM"), _T("DIACTFRM.1"));
  104. hr2 = UnregisterServer(CLSID_CDIDeviceActionConfigPage, _T("DIACTFRM"), _T("DIACTFRM.1"));
  105. //@@BEGIN_MSINTERNAL
  106. #ifdef DDKBUILD
  107. #ifdef DBG
  108. hr3 = UnregisterServer(CLSID_CDirectInputConfigUITest, _T("DIACTFRM"), _T("DIACTFRM.1"));
  109. #endif
  110. #endif
  111. //@@END_MSINTERNAL
  112. if (FAILED(hr1))
  113. return hr1;
  114. if (FAILED(hr2))
  115. return hr2;
  116. if (FAILED(hr3))
  117. return hr3;
  118. return S_OK;
  119. }