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.

85 lines
2.4 KiB

  1. //--------------------------------------------------------------------------------
  2. //
  3. // File: MCDTAB.CPP
  4. //
  5. // Implements the interfaces to the DLL.
  6. //
  7. //--------------------------------------------------------------------------------
  8. //Do this once in the entire build
  9. #define INITGUIDS
  10. #include "mcdtab.h"
  11. #include "clssfact.h"
  12. #include <initguid.h>
  13. // Count number of objects and number of locks.
  14. ULONG g_cObj = 0;
  15. ULONG g_cLock = 0;
  16. HINSTANCE g_hInst = NULL;
  17. // OLE-Registry magic number
  18. static const GUID CLSID_PlusPackCplExt =
  19. {0x49f1d180, 0x8ead, 0x11cf, {0x83, 0xac, 0x00, 0xaa, 0x00, 0xc2, 0x1d, 0xb6}};
  20. //---------------------------------------------------------------------------
  21. // DllMain()
  22. //---------------------------------------------------------------------------
  23. int APIENTRY DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID )
  24. {
  25. if( dwReason == DLL_PROCESS_ATTACH ) // Initializing
  26. {
  27. g_hInst = hInstance;
  28. DisableThreadLibraryCalls(hInstance);
  29. }
  30. return 1;
  31. }
  32. //---------------------------------------------------------------------------
  33. // DllGetClassObject()
  34. //
  35. // If someone calls with our CLSID, create an IClassFactory and pass it to
  36. // them, so they can create and use one of our CPropSheetExt objects.
  37. //
  38. //---------------------------------------------------------------------------
  39. STDAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID* ppvOut )
  40. {
  41. *ppvOut = NULL; // Assume Failure
  42. if( IsEqualCLSID( rclsid, CLSID_PlusPackCplExt ) )
  43. {
  44. //Check that we can provide the interface
  45. if( IsEqualIID( riid, IID_IUnknown) || IsEqualIID( riid, IID_IClassFactory ) )
  46. {
  47. //Return our IClassFactory for CPropSheetExt objects
  48. *ppvOut = (LPVOID* )new CClassFactory();
  49. if( NULL != *ppvOut )
  50. {
  51. //AddRef the object through any interface we return
  52. ((CClassFactory*)*ppvOut)->AddRef();
  53. return NOERROR;
  54. }
  55. return E_OUTOFMEMORY;
  56. }
  57. return E_NOINTERFACE;
  58. }
  59. else
  60. {
  61. return CLASS_E_CLASSNOTAVAILABLE;
  62. }
  63. }
  64. //---------------------------------------------------------------------------
  65. // DllCanUnloadNow()
  66. //
  67. // If we are not locked, and no objects are active, then we can exit.
  68. //
  69. //---------------------------------------------------------------------------
  70. STDAPI DllCanUnloadNow()
  71. {
  72. SCODE sc;
  73. //Our answer is whether there are any object or locks
  74. sc = (0L == g_cObj && 0 == g_cLock) ? S_OK : S_FALSE;
  75. return ResultFromScode(sc);
  76. }