diff --git a/Debug.7z b/Debug.7z deleted file mode 100644 index b39b98f..0000000 Binary files a/Debug.7z and /dev/null differ diff --git a/priformatcli/priformatcli.cpp b/priformatcli/priformatcli.cpp index dad909c..1a22feb 100644 --- a/priformatcli/priformatcli.cpp +++ b/priformatcli/priformatcli.cpp @@ -20,6 +20,32 @@ #include #include +LPWSTR AllocWideString (const std::wstring &str) +{ + size_t size = (str.length () + 1) * sizeof (WCHAR); + LPWSTR buf = (LPWSTR)CoTaskMemAlloc (size); + if (!buf) return nullptr; + ZeroMemory (buf, size); + wcscpy (buf, str.c_str ()); + return buf; +} +// ²âÊÔÓà +LPWSTR AllocWideString (LPCWSTR str) +{ + if (!str) return nullptr; + size_t size = (wcslen (str) + 1) * sizeof (WCHAR); + LPWSTR buf = (LPWSTR)CoTaskMemAlloc (size); + if (!buf) return nullptr; + ZeroMemory (buf, size); + wcscpy (buf, str); + return buf; +} +#define _wcsdup AllocWideString +#define free CoTaskMemFree +#define malloc CoTaskMemAlloc +#define realloc CoTaskMemRealloc +#define calloc(_cnt_, _size_) CoTaskMemAlloc (_cnt_ * _size_) + const std::wstring g_swMsResUriProtocolName = L"ms-resource:"; const size_t g_cbMsResPNameLength = lstrlenW (g_swMsResUriProtocolName.c_str ()); std::wstring g_swExcept = L""; diff --git a/priformatcli/priformatcli.h b/priformatcli/priformatcli.h index 05316b0..9c412f8 100644 --- a/priformatcli/priformatcli.h +++ b/priformatcli/priformatcli.h @@ -224,7 +224,7 @@ typedef class prifile { LPWSTR lpstr = nullptr; reltask release ([&lpstr] () { - if (lpstr) free (lpstr); + if (lpstr) PriFormatFreeString (lpstr); lpstr = nullptr; }); lpstr = GetPriResource (m_hPriFile, resname.c_str ()); diff --git a/priformatcli/priformatcli.vcxproj b/priformatcli/priformatcli.vcxproj index 383720d..623e57e 100644 --- a/priformatcli/priformatcli.vcxproj +++ b/priformatcli/priformatcli.vcxproj @@ -127,6 +127,7 @@ true WIN32;NDEBUG;_WINDOWS;_USRDLL;PRIFORMATCLI_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true + true Windows