1
0

Util.h 2.4 KB

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