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.

137 lines
3.7 KiB

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