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.

113 lines
3.2 KiB

  1. //--------------------------------------------------------------------------------
  2. //
  3. // File: EFFECTS.CPP
  4. //
  5. // Implements the interfaces to the DLL.
  6. //
  7. //--------------------------------------------------------------------------------
  8. #include "precomp.hxx"
  9. #pragma hdrstop
  10. //---------------------------------------------------------------------------
  11. // Globals
  12. //---------------------------------------------------------------------------
  13. //
  14. // Count number of objects and number of locks.
  15. //
  16. ULONG g_cObj = 0;
  17. ULONG g_cLock = 0;
  18. HINSTANCE g_hInst = NULL;
  19. BOOL g_RunningOnNT = FALSE;
  20. // OLE-Registry magic number
  21. static const GUID CLSID_PlusPackCplExt = { 0x41e300e0, 0x78b6, 0x11ce,
  22. { 0x84, 0x9b, 0x44, 0x45,
  23. 0x53, 0x54, 0x00, 0x00
  24. }
  25. };
  26. super_invalid;
  27. //---------------------------------------------------------------------------
  28. // DllMain()
  29. //---------------------------------------------------------------------------
  30. int APIENTRY DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID )
  31. {
  32. if( dwReason == DLL_PROCESS_ATTACH ) // Initializing
  33. {
  34. OSVERSIONINFO os;
  35. os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  36. if (GetVersionEx( &os ))
  37. {
  38. if (os.dwPlatformId == VER_PLATFORM_WIN32_NT)
  39. {
  40. g_RunningOnNT = TRUE;
  41. }
  42. }
  43. g_hInst = hInstance;
  44. DisableThreadLibraryCalls(hInstance);
  45. }
  46. return 1;
  47. }
  48. //---------------------------------------------------------------------------
  49. // DllGetClassObject()
  50. //
  51. // If someone calls with our CLSID, create an IClassFactory and pass it to
  52. // them, so they can create and use one of our CPropSheetExt objects.
  53. //
  54. //---------------------------------------------------------------------------
  55. STDAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID* ppvOut )
  56. {
  57. *ppvOut = NULL; // Assume Failure
  58. if( IsEqualCLSID( rclsid, CLSID_PlusPackCplExt ) )
  59. {
  60. //
  61. //Check that we can provide the interface
  62. //
  63. if( IsEqualIID( riid, IID_IUnknown) ||
  64. IsEqualIID( riid, IID_IClassFactory )
  65. )
  66. {
  67. //Return our IClassFactory for CPropSheetExt objects
  68. *ppvOut = (LPVOID* )new CClassFactory();
  69. if( NULL != *ppvOut )
  70. {
  71. //AddRef the object through any interface we return
  72. ((CClassFactory*)*ppvOut)->AddRef();
  73. return NOERROR;
  74. }
  75. return E_OUTOFMEMORY;
  76. }
  77. return E_NOINTERFACE;
  78. }
  79. else
  80. {
  81. return CLASS_E_CLASSNOTAVAILABLE;
  82. }
  83. }
  84. //---------------------------------------------------------------------------
  85. // DllCanUnloadNow()
  86. //
  87. // If we are not locked, and no objects are active, then we can exit.
  88. //
  89. //---------------------------------------------------------------------------
  90. STDAPI DllCanUnloadNow()
  91. {
  92. SCODE sc;
  93. //
  94. //Our answer is whether there are any object or locks
  95. //
  96. sc = (0L == g_cObj && 0 == g_cLock) ? S_OK : S_FALSE;
  97. return ResultFromScode(sc);
  98. }