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.

163 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C B A S E . H
  7. //
  8. // Contents: Basic common code.
  9. //
  10. // Notes: Pollute this under penalty of death.
  11. //
  12. // Author: shaunco 20 Sep 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _NCBASE_H_
  17. #define _NCBASE_H_
  18. #include "ncdefine.h" // for NOTHROW
  19. #define STACK_SIZE_DEFAULT 0
  20. #define STACK_SIZE_TINY 256
  21. #define STACK_SIZE_SMALL 65536
  22. #define STACK_SIZE_COMPACT 262144
  23. #define STACK_SIZE_LARGE 1048576
  24. #define STACK_SIZE_HUGE 5242880
  25. NOTHROW
  26. ULONG
  27. AddRefObj (
  28. IUnknown* punk);
  29. NOTHROW
  30. ULONG
  31. ReleaseObj (
  32. IUnknown* punk);
  33. NOTHROW
  34. DWORD
  35. DwWin32ErrorFromHr (
  36. HRESULT hr);
  37. inline
  38. BOOL
  39. FDwordWithinRange (
  40. DWORD dwLower,
  41. DWORD dw,
  42. DWORD dwUpper)
  43. {
  44. return ((dw >= dwLower) && (dw <= dwUpper));
  45. }
  46. NOTHROW
  47. HRESULT
  48. HrFromLastWin32Error ();
  49. HRESULT
  50. HrGetProcAddress (
  51. HMODULE hModule,
  52. PCSTR pszaFunction,
  53. FARPROC* ppfn);
  54. HRESULT
  55. HrLoadLibAndGetProcs (
  56. PCWSTR pszLibPath,
  57. UINT cFunctions,
  58. const PCSTR* apszaFunctionNames,
  59. HMODULE* phmod,
  60. FARPROC* apfn);
  61. inline
  62. HRESULT
  63. HrLoadLibAndGetProc (
  64. PCWSTR pszLibPath,
  65. PCSTR pszaFunctionName,
  66. HMODULE* phmod,
  67. FARPROC* ppfn)
  68. {
  69. return HrLoadLibAndGetProcs (pszLibPath, 1, &pszaFunctionName, phmod, ppfn);
  70. }
  71. HRESULT
  72. __cdecl
  73. HrGetProcAddressesV(
  74. HMODULE hModule, ...);
  75. HRESULT
  76. __cdecl
  77. HrLoadLibAndGetProcsV(
  78. PCWSTR pszLibPath,
  79. HMODULE* phModule,
  80. ...);
  81. HRESULT
  82. HrCreateEventWithWorldAccess(PCWSTR pszName, BOOL fManualReset,
  83. BOOL fInitialState, BOOL* pfAlreadyExists, HANDLE* phEvent);
  84. HRESULT
  85. HrCreateMutexWithWorldAccess(PCWSTR pszName, BOOL fInitialOwner,
  86. BOOL* pfAlreadyExists, HANDLE* phMutex);
  87. HRESULT
  88. HrCreateInstanceBase (REFCLSID rclsid, DWORD dwClsContext, REFIID riid, LPVOID * ppv);
  89. //+---------------------------------------------------------------------------
  90. //
  91. // Function: HrCreateInstance
  92. //
  93. // Purpose: Creates a COM object and sets default proxy settings.
  94. //
  95. // Arguments:
  96. // rclsid [in] See documentation for CoCreateInstance.
  97. // dwClsContext [in] ""
  98. // ppInter [out] Typed interface pointer using templates.
  99. //
  100. // Returns: S_OK on success. An error code otherwise.
  101. //
  102. // Author: mbend 1 Mar 2000
  103. //
  104. template <class Inter>
  105. inline HRESULT
  106. HrCreateInstance (
  107. REFCLSID rclsid,
  108. DWORD dwClsContext,
  109. Inter ** ppInter)
  110. {
  111. return HrCreateInstanceBase(rclsid, dwClsContext, __uuidof(Inter), reinterpret_cast<void**>(ppInter));
  112. }
  113. HRESULT
  114. HrQIAndSetProxyBlanketBase(IUnknown * pUnk, REFIID riid, void ** ppv);
  115. //+---------------------------------------------------------------------------
  116. //
  117. // Function: HrQIAndSetProxyBlanket
  118. //
  119. // Purpose: Performs QueryInterface and sets default proxy settings.
  120. //
  121. // Arguments:
  122. // pUnk [in] Interface pointer to perform QueryInterface on.
  123. // ppInter [out] Typed interface pointer using templates.
  124. //
  125. // Returns: S_OK on success. An error code otherwise.
  126. //
  127. // Author: mbend 1 Mar 2000
  128. //
  129. template <class Inter>
  130. inline HRESULT
  131. HrQIAndSetProxyBlanket (
  132. IUnknown * pUnk,
  133. Inter ** ppInter)
  134. {
  135. return HrQIAndSetProxyBlanketBase(pUnk, __uuidof(Inter), reinterpret_cast<void**>(ppInter));
  136. }
  137. #endif // _NCBASE_H_