common.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef NULLOSFT_ONLINEMEDIA_PLUGIN_COMMON_HEADER
  2. #define NULLOSFT_ONLINEMEDIA_PLUGIN_COMMON_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #include "../nu/trace.h"
  8. #define CSTR_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
  9. #ifndef ARRAYSIZE
  10. #define ARRAYSIZE(blah) (sizeof(blah)/sizeof(*blah))
  11. #endif
  12. #ifndef LONGX86
  13. #ifdef _WIN64
  14. #define LONGX86 LONG_PTR
  15. #else /*_WIN64*/
  16. #define LONGX86 LONG
  17. #endif /*_WIN64*/
  18. #endif // LONGX86
  19. #ifdef __cplusplus
  20. #define SENDMSG(__hwnd, __msgId, __wParam, __lParam) ::SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
  21. #else
  22. #define SENDMSG(__hwnd, __msgId, __wParam, __lParam) SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
  23. #endif // __cplusplus
  24. #define SENDMLIPC(__hwndML, __ipcMsgId, __param) SENDMSG((__hwndML), WM_ML_IPC, (WPARAM)(__param), (LPARAM)(__ipcMsgId))
  25. #define SENDWAIPC(__hwndWA, __ipcMsgId, __param) SENDMSG((__hwndWA), WM_WA_IPC, (WPARAM)(__param), (LPARAM)(__ipcMsgId))
  26. #define MSGRESULT(__hwnd, __result) { SetWindowLongPtrW((__hwnd), DWLP_MSGRESULT, ((LONGX86)(LONG_PTR)(__result))); return TRUE; }
  27. #define SENDCMD(__hwnd, __ctrlId, __eventId, __hctrl) (SENDMSG((__hwnd), WM_COMMAND, MAKEWPARAM(__ctrlId, __eventId), (LPARAM)(__hctrl)))
  28. #ifndef GetWindowStyle
  29. #define GetWindowStyle(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_STYLE))
  30. #endif //GetWindowStyle
  31. #ifndef GetWindowStyleEx
  32. #define GetWindowStyleEx(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_EXSTYLE))
  33. #endif // GetWindowStyleEx
  34. LPWSTR Plugin_MallocString(size_t cchLen);
  35. LPWSTR Plugin_ReAllocString(LPWSTR pszString, size_t cchLen);
  36. void Plugin_FreeString(LPWSTR pszString);
  37. LPWSTR Plugin_CopyString(LPCWSTR pszSource);
  38. LPSTR Plugin_MallocAnsiString(size_t cchLen);
  39. LPSTR Plugin_CopyAnsiString(LPCSTR pszSource);
  40. void Plugin_FreeAnsiString(LPSTR pszString);
  41. LPWSTR Plugin_DuplicateResString(LPCWSTR pszResource);
  42. void Plugin_FreeResString(LPWSTR pszResource);
  43. HRESULT Plugin_CopyResString(LPWSTR pszBuffer, INT cchBufferMax, LPCWSTR pszString);
  44. LPSTR Plugin_WideCharToMultiByte(UINT codePage, DWORD dwFlags, LPCWSTR lpWideCharStr, INT cchWideChar, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
  45. LPWSTR Plugin_MultiByteToWideChar(UINT codePage, DWORD dwFlags, LPCSTR lpMultiByteStr, INT cbMultiByte);
  46. void Plugin_SafeRelease(IUnknown *pUnk);
  47. HRESULT Plugin_MakeResourcePath(LPWSTR pszBuffer, INT cchBufferMax, LPCWSTR pszType, LPCWSTR pszName, UINT uFlags);
  48. HWND Plugin_GetDialogOwner(void);
  49. HRESULT Plugin_AppendFileFilter(LPTSTR pszBuffer, size_t cchBufferMax, LPCTSTR pName, LPCTSTR pFilter, LPTSTR *ppBufferOut, size_t *pRemaining, BOOL bShowFilter);
  50. HRESULT Plugin_BuildActionUrl(LPWSTR *ppStringOut, LPCWSTR pszAction, UINT *pServiceUid, size_t cchServiceUid);
  51. #define KWPARSER_ABORT ((UINT)0x00000000)
  52. #define KWPARSER_CONTINUE ((UINT)0x00000001)
  53. #define KWPARSER_FOUND ((UINT)0x80000000) // this is additional modifier
  54. typedef UINT (CALLBACK *KWPARSERPROC)(LPCWSTR /*pszKeyword*/, INT /*cchKeyword*/, ULONG_PTR /*user*/);
  55. INT Plugin_ParseKeywords(LPCWSTR input, INT cchInput, WCHAR separator, BOOL eatSpace, KWPARSERPROC callback, ULONG_PTR user);
  56. INT Plugin_MessageBox(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
  57. #endif //NULLOSFT_ONLINEMEDIA_PLUGIN_COMMON_HEADER