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.

130 lines
3.7 KiB

  1. #ifndef __UTIL_H
  2. #define __UTIL_H
  3. #define FT2LL(x) (((LONGLONG)((x).dwLowDateTime)) | (((LONGLONG)((x).dwHighDateTime))<<32))
  4. UINT HashKey(LPCWSTR pwszName);
  5. BOOL IsSysKeyMessage (MSG *pMsg); // Is this message an ALT key?
  6. BOOL IsGlobalKeyMessage(MSG *pMsg); // Is this message a key message that we want to handle globally?
  7. int IsVK_TABCycler (MSG *pMsg);
  8. inline BSTR VariantToBSTR(VARIANT &v) { return (v.vt == VT_BSTR) ? v.bstrVal : NULL; }
  9. inline long VariantToI4(VARIANT &v) { return (v.vt == VT_I4) ? v.lVal : 0; }
  10. void SetExceptionInfo(EXCEPINFO *pexcepinfo, WORD wCode);
  11. void AsciiToLower(LPWSTR pwsz);
  12. #define MAX_URL_STRING INTERNET_MAX_URL_LENGTH
  13. #define DEFINE_BEHAVIOR_CREATE_INSTANCE(cls) \
  14. static HRESULT CreateInstance(IElementBehavior **ppBehavior) \
  15. { \
  16. HRESULT hr = E_OUTOFMEMORY; \
  17. \
  18. cls * pB = new cls(); \
  19. if(pB) \
  20. { \
  21. hr = pB->QueryInterface( \
  22. IID_IElementBehavior, (void **) ppBehavior); \
  23. pB->Release(); \
  24. } \
  25. return hr; \
  26. }
  27. typedef struct _SA_BSTR
  28. {
  29. ULONG cb;
  30. WCHAR wsz[MAX_URL_STRING];
  31. } SA_BSTR;
  32. typedef HRESULT (STDMETHODCALLTYPE *PFNCREATEFACTORY)(IClassFactory **ppClassFactory);
  33. struct CThreadData
  34. {
  35. CThreadData();
  36. ~CThreadData();
  37. CComPtr<ITypeLib> m_spTypeLib;
  38. DWORD m_dwProxyFactory;
  39. static DWORD s_dwTlsIndex;
  40. static BOOL TlsSetValue(CThreadData *ptd);
  41. static CThreadData *TlsGetValue();
  42. static BOOL HaveData();
  43. static BOOL TlsAlloc();
  44. static BOOL TlsFree();
  45. };
  46. HRESULT PIDLToVariant(LPCITEMIDLIST pidl, CComVariant& v);
  47. BOOL IsGlobalOffline(void);
  48. void SetGlobalOffline(BOOL fOffline);
  49. HRESULT SaveDIBToFile(HBITMAP hbm, WCHAR * pszPath);
  50. void BoundWindowRectToMonitor(HWND hwnd, RECT *pRect);
  51. void CascadeWindowRectOnMonitor(HWND hwnd, RECT *pRect);
  52. BOOL IsWindowOverlayed(HWND hwndMatch, LONG x, LONG y);
  53. class CInterfaceMarshal
  54. {
  55. public:
  56. ~CInterfaceMarshal();
  57. BOOL Init(void);
  58. HRESULT Marshal(REFIID riid, IUnknown *pUnk);
  59. HRESULT UnMarshal(REFIID riid, void ** ppv);
  60. HRESULT WaitForSignal(HANDLE hSignallingThread, DWORD dwSecondsTimeout);
  61. protected:
  62. HANDLE m_hEvent;
  63. IStream *m_pStream;
  64. HRESULT m_hresMarshal;
  65. void Signal(void);
  66. };
  67. ////////////////////////////////////////////////////////////////////////////////
  68. interface IUniformResourceLocatorW;
  69. HRESULT MarsNavigateShortcut(IUnknown *pBrowser, IUniformResourceLocatorW* pUrl, LPCWSTR pszPath);
  70. HRESULT MarsNavigateShortcut(IUnknown *pTarget, LPCWSTR lpszPath);
  71. HRESULT MarsVariantToPath(VARIANT &varItem, CComBSTR &strPath);
  72. BOOL PathIsURLFileW(LPCWSTR lpszPath);
  73. ////////////////////////////////////////////////////////////////////////////////
  74. class CRegistryKey : public CRegKey
  75. {
  76. public:
  77. LONG SetLongValue(LONG lValue, LPCWSTR pwszValueName);
  78. LONG QueryLongValue(LONG& lValue, LPCWSTR pwszValueName);
  79. LONG SetBoolValue(BOOL bValue, LPCWSTR pwszValueName);
  80. LONG QueryBoolValue(BOOL& bValue, LPCWSTR pwszValueName);
  81. LONG SetBinaryValue(LPVOID pData, DWORD cbData, LPCWSTR pwszValueName);
  82. LONG QueryBinaryValue(LPVOID pData, DWORD cbData, LPCWSTR pwszValueName);
  83. };
  84. // GlobalSettingsRegKey lets you get a key to store miscellaneous data.
  85. // For example, CreateGlobalSubkey("MyOptions") might create the key
  86. // HKCU\Software\Microsoft\PCHealth\Global\MyOptions
  87. class CGlobalSettingsRegKey : public CRegistryKey
  88. {
  89. public:
  90. LONG CreateGlobalSubkey(LPCWSTR pwszSubkey);
  91. LONG OpenGlobalSubkey(LPCWSTR pwszSubkey);
  92. };
  93. ////////////////////////////////////////////////////////////////////////////////
  94. #endif //__UTIL_H