1
0

Util.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef NULLSOFT_PODCAST_PLUGIN_UTIL_HEADER
  2. #define NULLSOFT_PODCAST_PLUGIN_UTIL_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. #if defined (_WIN64)
  27. #define MSGRESULT(__hwnd, __result) { SetWindowLongPtrW((__hwnd), DWLP_MSGRESULT, ((LONGX86)(LONG_PTR)(__result))); return TRUE; }
  28. #else
  29. #define MSGRESULT(__hwnd, __result) { SetWindowLongPtrW((__hwnd), DWL_MSGRESULT, ((LONGX86)(LONG_PTR)(__result))); return TRUE; }
  30. #endif
  31. #define SENDCMD(__hwnd, __ctrlId, __eventId, __hctrl) (SENDMSG((__hwnd), WM_COMMAND, MAKEWPARAM(__ctrlId, __eventId), (LPARAM)(__hctrl)))
  32. LPWSTR Plugin_MallocString(size_t cchLen);
  33. LPWSTR Plugin_ReAllocString(LPWSTR pszString, size_t cchLen);
  34. void Plugin_FreeString(LPWSTR pszString);
  35. LPWSTR Plugin_CopyString(LPCWSTR pszSource);
  36. LPSTR Plugin_MallocAnsiString(size_t cchLen);
  37. LPSTR Plugin_CopyAnsiString(LPCSTR pszSource);
  38. void Plugin_FreeAnsiString(LPSTR pszString);
  39. LPWSTR Plugin_DuplicateResString(LPCWSTR pszResource);
  40. void Plugin_FreeResString(LPWSTR pszResource);
  41. HRESULT Plugin_CopyResString(LPWSTR pszBuffer, INT cchBufferMax, LPCWSTR pszString);
  42. LPSTR Plugin_WideCharToMultiByte(UINT codePage, DWORD dwFlags, LPCWSTR lpWideCharStr, INT cchWideChar, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
  43. LPWSTR Plugin_MultiByteToWideChar(UINT codePage, DWORD dwFlags, LPCSTR lpMultiByteStr, INT cbMultiByte);
  44. void Plugin_SafeRelease(IUnknown *pUnk);
  45. HRESULT Plugin_FileExtensionFromUrl(LPWSTR pszBuffer, INT cchBufferMax, LPCWSTR pszUrl, LPCWSTR defaultExtension);
  46. void Plugin_ReplaceBadPathChars(LPWSTR pszPath);
  47. INT Plugin_CleanDirectory(LPWSTR pszPath);
  48. HRESULT Plugin_EnsurePathExist(LPCWSTR pszDirectory);
  49. #endif // NULLSOFT_PODCAST_PLUGIN_UTIL_HEADER