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.

142 lines
4.8 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 000
  5. *
  6. * File: msaastub.h
  7. *
  8. * Contents: Provides stub implementations of OLEACC functions that
  9. * aren't available on backlevel OS's (Win95, NT4 SP3).
  10. * These implementations were copied from msaa.h, which
  11. * is no longer supported.
  12. *
  13. * History: 20-Jun-2000 jeffro Created
  14. *
  15. *--------------------------------------------------------------------------*/
  16. #pragma once
  17. #ifdef __cplusplus
  18. extern "C" { // Assume C declarations for C++
  19. #endif // __cplusplus
  20. // UnDefine these names so we can re-define them below.
  21. #undef AccessibleObjectFromWindow
  22. #undef LresultFromObject
  23. //
  24. // Define COMPILE_MSAA_STUBS to compile the stubs;
  25. // otherwise, you get the declarations.
  26. //
  27. // Exactly one source must include this with COMPILE_MSAA_STUBS defined.
  28. //
  29. #ifdef COMPILE_MSAA_STUBS
  30. //-----------------------------------------------------------------------------
  31. //
  32. // Implement the API stubs.
  33. //
  34. //-----------------------------------------------------------------------------
  35. #ifndef MSAA_FNS_DEFINED
  36. // OLEACC
  37. HRESULT (WINAPI* g_pfnAccessibleObjectFromWindow)(HWND,DWORD,REFIID,void **) = NULL;
  38. LRESULT (WINAPI* g_pfnLresultFromObject)(REFIID,WPARAM,LPUNKNOWN) = NULL;
  39. // STATUS
  40. BOOL g_fMSAAInitDone = FALSE;
  41. #endif
  42. //-----------------------------------------------------------------------------
  43. // This is the function that checks that all the required API's exist, and
  44. // then allows apps that include this file to call the real functions if they
  45. // exist, or the 'stubs' if they do not. This function is only called by the
  46. // stub functions - client code never needs to call this.
  47. //-----------------------------------------------------------------------------
  48. BOOL InitMSAAStubs(void)
  49. {
  50. HMODULE hOleacc;
  51. if (g_fMSAAInitDone)
  52. {
  53. return g_pfnLresultFromObject != NULL;
  54. }
  55. hOleacc = GetModuleHandle(TEXT("OLEACC.DLL"));
  56. if (!hOleacc)
  57. hOleacc = LoadLibrary(TEXT("OLEACC.DLL"));
  58. if ((hOleacc) &&
  59. (*(FARPROC*)&g_pfnAccessibleObjectFromWindow = GetProcAddress(hOleacc,"AccessibleObjectFromWindow")) &&
  60. (*(FARPROC*)&g_pfnLresultFromObject = GetProcAddress(hOleacc,"LresultFromObject")))
  61. {
  62. g_fMSAAInitDone = TRUE;
  63. return TRUE;
  64. }
  65. else
  66. {
  67. g_pfnAccessibleObjectFromWindow = NULL;
  68. g_pfnLresultFromObject = NULL;
  69. g_fMSAAInitDone = TRUE;
  70. return FALSE;
  71. }
  72. }
  73. //-----------------------------------------------------------------------------
  74. //
  75. // Fake implementations of MSAA APIs that return error codes.
  76. // No special parameter validation is made since these run in client code
  77. //
  78. //-----------------------------------------------------------------------------
  79. //-----------------------------------------------------------------------------
  80. // Fake implementation of AccessibleObjectFromWindow. Returns E_NOTIMPL if the
  81. // real API is not present.
  82. //-----------------------------------------------------------------------------
  83. HRESULT WINAPI xAccessibleObjectFromWindow (HWND hWnd,DWORD dwID,REFIID riidInterface,
  84. void ** ppvObject)
  85. {
  86. if (InitMSAAStubs())
  87. return g_pfnAccessibleObjectFromWindow (hWnd,dwID,riidInterface,ppvObject);
  88. return (E_NOTIMPL);
  89. }
  90. //-----------------------------------------------------------------------------
  91. // Fake implementation of LresultFromObject. Returns E_NOTIMPL if the real API
  92. // is not present.
  93. //-----------------------------------------------------------------------------
  94. LRESULT WINAPI xLresultFromObject (REFIID riidInterface,WPARAM wParam,LPUNKNOWN pUnk)
  95. {
  96. if (InitMSAAStubs())
  97. return g_pfnLresultFromObject (riidInterface,wParam,pUnk);
  98. return (E_NOTIMPL);
  99. }
  100. #undef COMPILE_MSAA_STUBS
  101. #else // COMPILE_MSAA_STUBS
  102. extern HRESULT WINAPI xAccessibleObjectFromWindow (HWND hWnd,
  103. DWORD dwID,
  104. REFIID riidInterface,
  105. void ** ppvObject);
  106. extern LRESULT WINAPI xLresultFromObject (REFIID riidInterface,
  107. WPARAM wParam,
  108. LPUNKNOWN pUnk);
  109. #endif // COMPILE_MSAA_STUBS
  110. //
  111. // build defines that replace the regular APIs with our versions
  112. //
  113. #define AccessibleObjectFromWindow xAccessibleObjectFromWindow
  114. #define LresultFromObject xLresultFromObject
  115. #ifdef __cplusplus
  116. }
  117. #endif // __cplusplus