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.

134 lines
3.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994.
  5. //
  6. // File: hkOle32x.h
  7. //
  8. // Contents: OLE 32 Extensions Header File
  9. //
  10. // Functions:
  11. //
  12. // History: 29-Nov-94 Garry Lenz Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef _HKOLE32X_H_
  16. #define _HKOLE32X_H_
  17. #include <Windows.h>
  18. #include <TChar.h>
  19. interface IHookOleObject;
  20. STDAPI CoGetCurrentLogicalThreadId(GUID* pguidLogicalThreadId);
  21. STDAPI GetHookInterface(IHookOleObject** pIHookOleObject);
  22. STDAPI EnableHookObject(BOOL fNewState, BOOL* pfPrevState);
  23. #define GUID_STRING_LENGTH 39
  24. #define CLSID_STRING_LENGTH 39
  25. #define IID_STRING_LENGTH 39
  26. #define PROGID_STRING_LENGTH 40
  27. // used by INITHOOKOBJECT
  28. inline HRESULT CLSIDFromStringA(LPSTR lpsz, LPCLSID lpclsid)
  29. {
  30. LPWSTR lpwsz = new WCHAR[(strlen(lpsz)+1)];
  31. MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, lpsz, -1, lpwsz, lstrlenA(lpsz)+1);
  32. HRESULT hr = CLSIDFromString(lpwsz, lpclsid);
  33. delete lpwsz;
  34. return hr;
  35. }
  36. ///////////////////////////////////////////////////////////////////////////////
  37. ///////////////////////////////////////////////////////////////////////////////
  38. #ifdef OLETOOLS
  39. // these are needed only by the tools, not internally by ole32. we ifdef
  40. // it here to maintain source compatibility.
  41. inline BOOL IsOle32ProcDefined(LPCSTR pszProcName)
  42. {
  43. BOOL fResult = FALSE;
  44. HINSTANCE hInstOle32 = LoadLibrary(__T("OLE32.DLL"));
  45. if (hInstOle32)
  46. {
  47. if (GetProcAddress(hInstOle32, pszProcName) != NULL)
  48. fResult = TRUE;
  49. FreeLibrary(hInstOle32);
  50. }
  51. return fResult;
  52. }
  53. inline HINSTANCE CoLoadLibrary(LPSTR lpszLibName, BOOL bAutoFree)
  54. {
  55. LPWSTR lpwsz = new WCHAR[(strlen(lpszLibName)+1)];
  56. MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, lpszLibName, -1, lpwsz, lstrlenA(lpszLibName)+1);
  57. HINSTANCE hInstance = CoLoadLibrary(lpwsz, bAutoFree);
  58. delete lpwsz;
  59. return hInstance;
  60. }
  61. inline HRESULT IIDFromString(LPSTR lpsz, LPIID lpiid)
  62. {
  63. LPWSTR lpwsz = new WCHAR[(strlen(lpsz)+1)];
  64. MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, lpsz, -1, lpwsz, lstrlenA(lpsz)+1);
  65. HRESULT hr = IIDFromString(lpwsz, lpiid);
  66. delete lpwsz;
  67. return hr;
  68. }
  69. inline HRESULT StringFromIID(REFIID riid, LPSTR FAR* lplpsz)
  70. {
  71. HRESULT hr = StringFromIID(riid, (LPWSTR*)lplpsz);
  72. if (hr == S_OK)
  73. {
  74. WCHAR wsz[IID_STRING_LENGTH];
  75. lstrcpyW(wsz, (LPWSTR)*lplpsz);
  76. WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsz, -1, *lplpsz, lstrlenW(wsz), NULL, NULL);
  77. }
  78. return hr;
  79. }
  80. inline HRESULT StringFromCLSID(REFCLSID rclsid, LPSTR FAR* lplpsz)
  81. {
  82. HRESULT hr = StringFromCLSID(rclsid, (LPWSTR*)lplpsz);
  83. if (hr == S_OK)
  84. {
  85. WCHAR wsz[CLSID_STRING_LENGTH];
  86. lstrcpyW(wsz, (LPWSTR)*lplpsz);
  87. WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsz, -1, *lplpsz, lstrlenW(wsz), NULL, NULL);
  88. }
  89. return hr;
  90. }
  91. inline HRESULT ProgIDFromCLSID(REFCLSID rclsid, LPSTR FAR* lplpsz)
  92. {
  93. HRESULT hr = ProgIDFromCLSID(rclsid, (LPWSTR*)lplpsz);
  94. if (hr == S_OK)
  95. {
  96. WCHAR wsz[PROGID_STRING_LENGTH];
  97. lstrcpyW(wsz, (LPWSTR)*lplpsz);
  98. WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsz, -1, *lplpsz, lstrlenW(wsz), NULL, NULL);
  99. }
  100. return hr;
  101. }
  102. inline HRESULT CLSIDFromProgID(LPCSTR lpszProgID, LPCLSID lpclsid)
  103. {
  104. LPWSTR lpwsz = new WCHAR[(strlen(lpszProgID)+1)];
  105. MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, lpszProgID, -1, lpwsz, lstrlenA(lpszProgID)+1);
  106. HRESULT hr = CLSIDFromProgID(lpwsz, lpclsid);
  107. delete lpwsz;
  108. return hr;
  109. }
  110. ///////////////////////////////////////////////////////////////////////////////
  111. ///////////////////////////////////////////////////////////////////////////////
  112. #endif
  113. #endif // _HKOLE32X_H_