Leaked source code of windows server 2003
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.

136 lines
3.7 KiB

  1. /*****************************************************************************
  2. *
  3. * fndcf.c - IClassFactory interface
  4. *
  5. *****************************************************************************/
  6. #include "fnd.h"
  7. #ifdef _WIN64
  8. #pragma pack(push,8)
  9. #endif // _WIN64
  10. /*****************************************************************************
  11. *
  12. * The sqiffle for this file.
  13. *
  14. *****************************************************************************/
  15. #define sqfl sqflFactory
  16. /*****************************************************************************
  17. *
  18. * Declare the interfaces we will be providing.
  19. *
  20. *****************************************************************************/
  21. Primary_Interface(CFndFactory, IClassFactory);
  22. /*****************************************************************************
  23. *
  24. * CFndFactory
  25. *
  26. * Really nothing doing.
  27. *
  28. *****************************************************************************/
  29. typedef struct CFndFactory {
  30. /* Supported interfaces */
  31. IClassFactory cf;
  32. } CFndFactory, FCF, *PFCF;
  33. typedef IClassFactory CF, *PCF;
  34. /*****************************************************************************
  35. *
  36. * CFndFactory_QueryInterface (from IUnknown)
  37. * CFndFactory_AddRef (from IUnknown)
  38. * CFndFactory_Finalize (from Common)
  39. * CFndFactory_Release (from IUnknown)
  40. *
  41. *****************************************************************************/
  42. #define CFndFactory_QueryInterface Common_QueryInterface
  43. #define CFndFactory_AddRef Common_AddRef
  44. #define CFndFactory_Release Common_Release
  45. #define CFndFactory_Finalize Common_Finalize
  46. /*****************************************************************************
  47. *
  48. * CFndFactory_CreateInstance (from IClassFactory)
  49. *
  50. *****************************************************************************/
  51. STDMETHODIMP
  52. CFndFactory_CreateInstance(PCF pcf, LPUNKNOWN punkOuter, RIID riid, PPV ppvObj)
  53. {
  54. HRESULT hres;
  55. if (!punkOuter) {
  56. /* The only object we know how to create is a context menu */
  57. hres = CFndCm_New(riid, ppvObj);
  58. } else { /* Does anybody support aggregation any more? */
  59. hres = ResultFromScode(CLASS_E_NOAGGREGATION);
  60. }
  61. return hres;
  62. }
  63. /*****************************************************************************
  64. *
  65. * CFndFactory_LockServer (from IClassFactory)
  66. *
  67. * Locking the server is identical to
  68. * creating an object and not releasing it until you want to unlock
  69. * the server.
  70. *
  71. *****************************************************************************/
  72. STDMETHODIMP
  73. CFndFactory_LockServer(PCF pcf, BOOL fLock)
  74. {
  75. PFCF this = IToClass(CFndFactory, cf, pcf);
  76. if (fLock) {
  77. InterlockedIncrement((LPLONG)&g_cRef);
  78. } else {
  79. InterlockedDecrement((LPLONG)&g_cRef);
  80. }
  81. return NOERROR;
  82. }
  83. /*****************************************************************************
  84. *
  85. * CFndFactory_New
  86. *
  87. *****************************************************************************/
  88. STDMETHODIMP
  89. CFndFactory_New(RIID riid, PPV ppvObj)
  90. {
  91. HRESULT hres;
  92. if (IsEqualIID(riid, &IID_IClassFactory)) {
  93. hres = Common_New(CFndFactory, ppvObj);
  94. } else {
  95. hres = ResultFromScode(E_NOINTERFACE);
  96. }
  97. return hres;
  98. }
  99. /*****************************************************************************
  100. *
  101. * The long-awaited vtbl
  102. *
  103. *****************************************************************************/
  104. #pragma BEGIN_CONST_DATA
  105. Primary_Interface_Begin(CFndFactory, IClassFactory)
  106. CFndFactory_CreateInstance,
  107. CFndFactory_LockServer,
  108. Primary_Interface_End(CFndFactory, IClassFactory)
  109. #ifdef _WIN64
  110. #pragma pack(pop)
  111. #endif //_WIN64