#6037 Remove crazy LoadString wrapper

This commit is contained in:
Andrew Nelless 2017-05-12 01:41:17 +01:00
parent 823868f767
commit 3e6b6dc7b8
1 changed files with 5 additions and 22 deletions

View File

@ -29,31 +29,14 @@
String String
MSWindowsUtil::getString(HINSTANCE instance, DWORD id) MSWindowsUtil::getString(HINSTANCE instance, DWORD id)
{ {
char buffer[1024]; char* msg = NULL;
int size = static_cast<int>(sizeof(buffer) / sizeof(buffer[0])); int n = LoadString(instance, id, reinterpret_cast<LPSTR>(&msg), 0);
char* msg = buffer;
// load string if (n <= 0) {
int n = LoadString(instance, id, msg, size); return String();
msg[n] = '\0';
if (n < size) {
return msg;
} }
// not enough buffer space. keep trying larger buffers until return String (msg, n);
// we get the whole string.
msg = NULL;
do {
size <<= 1;
delete[] msg;
char* msg = new char[size];
n = LoadString(instance, id, msg, size);
} while (n == size);
msg[n] = '\0';
String result(msg);
delete[] msg;
return result;
} }
String String