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.

98 lines
2.2 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: oleimpl.cxx
  4. //
  5. // Contents: This file contins the DLL entry points
  6. // LibMain
  7. // DllGetClassObject (Bindings key func)
  8. // CBasicBndCF (class factory)
  9. // CBasicBnd (actual class implementation)
  10. //
  11. // Classes: CBasicBndCF, CBasicBnd
  12. //
  13. //
  14. // History: 30-Nov-92 SarahJ Created
  15. //
  16. //---------------------------------------------------------------------
  17. #include <windows.h>
  18. #include <ole2.h>
  19. #include <bscbnd.hxx>
  20. extern ULONG g_UseCount;
  21. CBasicBndCF *g_pcf = NULL;
  22. //+-------------------------------------------------------------------
  23. //
  24. // Function: LibMain
  25. //
  26. // Synopsis: Entry point to DLL - does little else
  27. //
  28. // Arguments:
  29. //
  30. // Returns: TRUE
  31. //
  32. // History: 21-Nov-92 SarahJ Created
  33. //
  34. //--------------------------------------------------------------------
  35. extern "C" BOOL WINAPI DLLMain (HANDLE hDll,
  36. DWORD dwReason,
  37. LPVOID pvReserved)
  38. {
  39. return TRUE;
  40. }
  41. //+-------------------------------------------------------------------
  42. //
  43. // Function: DllGetClassObject
  44. //
  45. // Synopsis: Called by client (from within BindToObject et al)
  46. // interface requested should be IUnknown or IClassFactory -
  47. // Creates ClassFactory object and returns pointer to it
  48. //
  49. // Arguments: REFCLSID clsid - class id
  50. // REFIID iid - interface id
  51. // void FAR* FAR* ppv- pointer to class factory interface
  52. //
  53. // Returns: TRUE
  54. //
  55. // History: 21-Nov-92 SarahJ Created
  56. //
  57. //--------------------------------------------------------------------
  58. STDAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void FAR* FAR* ppv)
  59. {
  60. if (!IsEqualIID(iid, IID_IUnknown) && !IsEqualIID(iid, IID_IClassFactory))
  61. {
  62. return E_NOINTERFACE;
  63. }
  64. if (IsEqualCLSID(clsid, CLSID_BasicBnd))
  65. {
  66. if (g_pcf)
  67. {
  68. *ppv = g_pcf;
  69. g_pcf->AddRef();
  70. }
  71. else
  72. {
  73. *ppv = new CBasicBndCF();
  74. }
  75. return (*ppv != NULL) ? S_OK : E_FAIL;
  76. }
  77. return E_FAIL;
  78. }
  79. STDAPI DllCanUnloadNow(void)
  80. {
  81. return (g_UseCount == 0) ? S_OK : S_FALSE;
  82. }