X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03647350fc7cd141953c72e0284e928847d30f44..4b601a59b5f303a8866a18c90fff90aff393c6b7:/src/msw/utilsgui.cpp diff --git a/src/msw/utilsgui.cpp b/src/msw/utilsgui.cpp index 513a56f810..68ca45db20 100644 --- a/src/msw/utilsgui.cpp +++ b/src/msw/utilsgui.cpp @@ -108,7 +108,7 @@ bool wxCheckForInterrupt(wxWindow *wnd) // Returns NULL or newly-allocated memory, so use delete[] to clean up. #ifndef __WXMICROWIN__ -wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType) +char *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType, int* pLen /* = NULL */) { HRSRC hResource = ::FindResource(wxGetInstance(), resourceName.wx_str(), @@ -120,15 +120,16 @@ wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourc if ( hData == 0 ) return NULL; - wxChar *theText = (wxChar *)::LockResource(hData); + void *theText = ::LockResource(hData); if ( !theText ) return NULL; // Not all compilers put a zero at the end of the resource (e.g. BC++ doesn't). // so we need to find the length of the resource. - int len = ::SizeofResource(wxGetInstance(), hResource) + 1; - wxChar *s = new wxChar[len]; - wxStrlcpy(s, theText, len); + int len = ::SizeofResource(wxGetInstance(), hResource); + char *s = new char[len + 1]; + memcpy(s, theText, len); + s[len] = '\0'; // NUL-terminate in case the resource itself wasn't // Obsolete in WIN32 #ifndef __WIN32__ @@ -138,6 +139,9 @@ wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourc // No need?? // GlobalFree(hData); + if (pLen) + *pLen = len; + return s; } #endif // __WXMICROWIN__