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.

54 lines
2.8 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All rights reserved.
  2. //
  3. // Helper routines that wrap called to functions in oleaut32. This enables us to
  4. // compile free from any dependency on oleaut32.dll. Each function takes a bool as
  5. // its first argument, which is true if the oleaut32 function is to be called. When
  6. // false, our own implementation of the function is used. In this case, some
  7. // functionality is lost. For example, only certain types of VARIANT variables are
  8. // handled correctly in the abscence of oleaut32.
  9. //
  10. // oleaut32 is demand-loaded when the first function is called with a true parameter,
  11. // unless one of the following is defined:
  12. // DMS_ALWAYS_USE_OLEAUT
  13. // causes oleaut32 to be used in all cases and statically linked.
  14. // DMS_NEVER_USE_OLEAUT
  15. // for use on platforms where oleaut32 isn't available -- always uses the
  16. // internal functions and asserts if true is ever passed.
  17. //
  18. #pragma once
  19. // If this GUID is passed for riid when calling Invoke, the DirectMusic automation methods will behave according to a special
  20. // calling convention whereby the functions in this file are used (with fUseOleAut as false) instead of those from
  21. // oleaut32.
  22. const GUID g_guidInvokeWithoutOleaut = { 0x1fcc43db, 0xbad8, 0x4a88, { 0xbc, 0x77, 0x4e, 0x1a, 0xe0, 0x2d, 0x9c, 0x79 } };
  23. #ifdef DMS_ALWAYS_USE_OLEAUT
  24. // VARIANTs
  25. inline void DMS_VariantInit(bool fUseOleAut, VARIANTARG *pvarg) { VariantInit(pvarg); }
  26. inline HRESULT DMS_VariantClear(bool fUseOleAut, VARIANTARG *pvarg) { return VariantClear(pvarg); }
  27. inline HRESULT DMS_VariantCopy(bool fUseOleAut, VARIANTARG *pvargDest, const VARIANTARG *pvargSrc) { return VariantCopy(pvargDest, const_cast<VARIANT*>(pvargSrc)); }
  28. inline HRESULT DMS_VariantChangeType(bool fUseOleAut, VARIANTARG *pvargDest, VARIANTARG *pvarSrc, USHORT wFlags, VARTYPE vt) { return VariantChangeType(pvargDest, pvarSrc, wFlags, vt); }
  29. // BSTRs
  30. inline BSTR DMS_SysAllocString(bool fUseOleAut, const OLECHAR *pwsz) { return SysAllocString(pwsz); }
  31. inline void DMS_SysFreeString(bool fUseOleAut, BSTR bstr) { SysFreeString(bstr); }
  32. #else
  33. // VARIANTs
  34. // Without fUseOleAut, Only handles types VT_I4, VT_I2, VT_UNKNOWN, VT_DISPATCH and
  35. // doesn't call dispatch pointers for their value properties.
  36. void DMS_VariantInit(bool fUseOleAut, VARIANTARG *pvarg);
  37. HRESULT DMS_VariantClear(bool fUseOleAut, VARIANTARG * pvarg);
  38. HRESULT DMS_VariantCopy(bool fUseOleAut, VARIANTARG * pvargDest, const VARIANTARG * pvargSrc);
  39. HRESULT DMS_VariantChangeType(bool fUseOleAut, VARIANTARG * pvargDest, VARIANTARG * pvarSrc, USHORT wFlags, VARTYPE vt);
  40. // BSTRs
  41. // Without fUseOleAut, doesn't include size prefix -- plain C WCHAR strings.
  42. BSTR DMS_SysAllocString(bool fUseOleAut, const OLECHAR *pwsz);
  43. void DMS_SysFreeString(bool fUseOleAut, BSTR bstr);
  44. #endif