Use Unicode versions of Win32 functions, issue #261
This commit is contained in:
parent
e4dc8ae94b
commit
e7bebba3d3
16 changed files with 91 additions and 86 deletions
|
@ -1806,7 +1806,7 @@ emptyProc CDriverD3D::getWindowProc()
|
|||
|
||||
IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon)
|
||||
{
|
||||
switch (::MessageBox (_HWnd, message, title, ((type==retryCancelType)?MB_RETRYCANCEL:
|
||||
switch (::MessageBoxW (_HWnd, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
|
||||
(type==yesNoCancelType)?MB_YESNOCANCEL:
|
||||
(type==okCancelType)?MB_OKCANCEL:
|
||||
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:
|
||||
|
|
|
@ -2622,7 +2622,7 @@ IDriver::TMessageBoxId CDriverGL::systemMessageBox (const char* message, const c
|
|||
{
|
||||
H_AUTO_OGL(CDriverGL_systemMessageBox)
|
||||
#ifdef NL_OS_WINDOWS
|
||||
switch (::MessageBox (NULL, message, title, ((type==retryCancelType)?MB_RETRYCANCEL:
|
||||
switch (::MessageBoxW (NULL, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL:
|
||||
(type==yesNoCancelType)?MB_YESNOCANCEL:
|
||||
(type==okCancelType)?MB_OKCANCEL:
|
||||
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:
|
||||
|
|
|
@ -199,11 +199,11 @@ bool CCmdArgs::parse(const std::string &args)
|
|||
std::vector<std::string> argv;
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
char str[4096];
|
||||
uint len = GetModuleFileNameA(NULL, str, 4096);
|
||||
wchar_t str[4096];
|
||||
uint len = GetModuleFileNameW(NULL, str, 4096);
|
||||
|
||||
if (len && len < 4096)
|
||||
argv.push_back(str);
|
||||
argv.push_back(wideToUtf8(str));
|
||||
#endif
|
||||
|
||||
std::string::size_type pos1 = 0, pos2 = 0;
|
||||
|
|
|
@ -310,9 +310,9 @@ static DWORD __stdcall GetModuleBase(HANDLE hProcess, DWORD dwReturnAddress)
|
|||
&memoryBasicInfo, sizeof(memoryBasicInfo)))
|
||||
{
|
||||
DWORD cch = 0;
|
||||
char szFile[MAX_PATH] = { 0 };
|
||||
wchar_t szFile[MAX_PATH] = { 0 };
|
||||
|
||||
cch = GetModuleFileNameA((HINSTANCE)memoryBasicInfo.AllocationBase,
|
||||
cch = GetModuleFileNameW((HINSTANCE)memoryBasicInfo.AllocationBase,
|
||||
szFile, MAX_PATH);
|
||||
|
||||
if (cch && (lstrcmpA(szFile, "DBFN")== 0))
|
||||
|
@ -527,9 +527,9 @@ public:
|
|||
string progname;
|
||||
if(!shortExc.empty() || !longExc.empty())
|
||||
{
|
||||
char name[1024];
|
||||
GetModuleFileNameA (NULL, name, 1023);
|
||||
progname = CFile::getFilename(name);
|
||||
wchar_t name[1024];
|
||||
GetModuleFileNameW (NULL, name, 1023);
|
||||
progname = CFile::getFilename(wideToUtf8(name));
|
||||
progname += " ";
|
||||
}
|
||||
|
||||
|
|
|
@ -286,14 +286,14 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
|
|||
// WARNING: READ THIS !!!!!!!!!!!!!!!! ///////////////////////////
|
||||
// If at the release time, it freezes here, it's a microsoft bug:
|
||||
// http://support.microsoft.com/support/kb/articles/q173/2/60.asp
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(str2).c_str());
|
||||
OutputDebugStringW(utf8ToWide(str2));
|
||||
}
|
||||
else
|
||||
{
|
||||
sint count = 0;
|
||||
uint n = (uint)strlen(message);
|
||||
std::string s(&str2.c_str()[0], (str2.size() - n));
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str());
|
||||
OutputDebugStringW(utf8ToWide(s));
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
@ -301,15 +301,15 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
|
|||
if((n - count) < maxOutString )
|
||||
{
|
||||
s = std::string(&message[count], (n - count));
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str());
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8("\n").c_str());
|
||||
OutputDebugStringW(utf8ToWide(s));
|
||||
OutputDebugStringW(L"\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = std::string(&message[count] , count + maxOutString);
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(s).c_str());
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8("\n\t\t\t").c_str());
|
||||
OutputDebugStringW(utf8ToWide(s));
|
||||
OutputDebugStringW(L"\n\t\t\t");
|
||||
count += maxOutString;
|
||||
}
|
||||
}
|
||||
|
@ -323,13 +323,13 @@ void CStdDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mess
|
|||
if (pos+1000 < args.CallstackAndLog.size ())
|
||||
{
|
||||
splited = args.CallstackAndLog.substr (pos, 1000);
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(splited).c_str());
|
||||
OutputDebugStringW(utf8ToWide(splited));
|
||||
pos += 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
splited = args.CallstackAndLog.substr (pos);
|
||||
OutputDebugStringW((LPCWSTR)ucstring::makeFromUtf8(splited).c_str());
|
||||
OutputDebugStringW(utf8ToWide(splited));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ NL_LIB_HANDLE nlLoadLibrary(const std::string &libName)
|
|||
{
|
||||
NL_LIB_HANDLE res = 0;
|
||||
#ifdef NL_OS_WINDOWS
|
||||
res = LoadLibrary(libName.c_str());
|
||||
res = LoadLibraryW(utf8ToWide(libName));
|
||||
#elif defined(NL_OS_UNIX)
|
||||
res = dlopen(libName.c_str(), RTLD_NOW);
|
||||
#else
|
||||
|
|
|
@ -59,9 +59,9 @@ void CLog::setDefaultProcessName ()
|
|||
#ifdef NL_OS_WINDOWS
|
||||
if ((*_ProcessName).empty())
|
||||
{
|
||||
char name[1024];
|
||||
GetModuleFileName (NULL, name, 1023);
|
||||
(*_ProcessName) = CFile::getFilename(name);
|
||||
wchar_t name[1024];
|
||||
GetModuleFileNameW(NULL, name, 1023);
|
||||
(*_ProcessName) = CFile::getFilename(wideToUtf8(name));
|
||||
}
|
||||
#else
|
||||
if ((*_ProcessName).empty())
|
||||
|
|
|
@ -227,28 +227,28 @@ static void displayCallStack (CLog *log)
|
|||
|
||||
if (symbolPath.empty())
|
||||
{
|
||||
CHAR tmpPath[stringSize];
|
||||
wchar_t tmpPath[stringSize];
|
||||
|
||||
symbolPath = ".";
|
||||
|
||||
if (GetEnvironmentVariable ("_NT_SYMBOL_PATH", tmpPath, stringSize))
|
||||
if (GetEnvironmentVariableW (L"_NT_SYMBOL_PATH", tmpPath, stringSize))
|
||||
{
|
||||
symbolPath += ";";
|
||||
symbolPath += tmpPath;
|
||||
symbolPath += wideToUtf8(tmpPath);
|
||||
}
|
||||
|
||||
if (GetEnvironmentVariable ("_NT_ALTERNATE_SYMBOL_PATH", tmpPath, stringSize))
|
||||
if (GetEnvironmentVariableW (L"_NT_ALTERNATE_SYMBOL_PATH", tmpPath, stringSize))
|
||||
{
|
||||
symbolPath += ";";
|
||||
symbolPath += tmpPath;
|
||||
symbolPath += wideToUtf8(tmpPath);
|
||||
}
|
||||
|
||||
if (GetEnvironmentVariable ("SYSTEMROOT", tmpPath, stringSize))
|
||||
if (GetEnvironmentVariableW (L"SYSTEMROOT", tmpPath, stringSize))
|
||||
{
|
||||
symbolPath += ";";
|
||||
symbolPath += tmpPath;
|
||||
symbolPath += wideToUtf8(tmpPath);
|
||||
symbolPath += ";";
|
||||
symbolPath += tmpPath;
|
||||
symbolPath += wideToUtf8(tmpPath);
|
||||
symbolPath += "\\system32";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -681,11 +681,11 @@ std::string CPath::getCurrentPath ()
|
|||
|
||||
std::string CFileContainer::getCurrentPath ()
|
||||
{
|
||||
char buffer [1024];
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
return standardizePath(_getcwd(buffer, 1024), false);
|
||||
wchar_t buffer[1024];
|
||||
return standardizePath(wideToUtf8(_wgetcwd(buffer, 1024)), false);
|
||||
#else
|
||||
char buffer [1024];
|
||||
return standardizePath(getcwd(buffer, 1024), false);
|
||||
#endif
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ bool CFileContainer::setCurrentPath (const std::string &path)
|
|||
int res;
|
||||
//nldebug("Change current path to '%s' (current path is '%s')", path.c_str(), getCurrentPath().c_str());
|
||||
#ifdef NL_OS_WINDOWS
|
||||
res = _chdir(path.c_str());
|
||||
res = _wchdir(utf8ToWide(path));
|
||||
#else
|
||||
res = chdir(path.c_str());
|
||||
#endif
|
||||
|
@ -756,11 +756,11 @@ std::string CFileContainer::getFullPath (const std::string &path, bool addFinalS
|
|||
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
# define dirent WIN32_FIND_DATA
|
||||
# define dirent WIN32_FIND_DATAW
|
||||
# define DIR void
|
||||
|
||||
static string sDir;
|
||||
static WIN32_FIND_DATA findData;
|
||||
static WIN32_FIND_DATAW findData;
|
||||
static HANDLE hFind;
|
||||
|
||||
DIR *opendir (const char *path)
|
||||
|
@ -792,13 +792,12 @@ dirent *readdir (DIR *dir)
|
|||
// first visit in this directory : FindFirstFile()
|
||||
if (hFind == NULL)
|
||||
{
|
||||
string fullPath = CPath::standardizePath(sDir) + "*";
|
||||
hFind = FindFirstFileA (fullPath.c_str(), &findData);
|
||||
hFind = FindFirstFileW (utf8ToWide(CPath::standardizePath(sDir) + "*"), &findData);
|
||||
}
|
||||
// directory already visited : FindNextFile()
|
||||
else
|
||||
{
|
||||
if (!FindNextFileA (hFind, &findData))
|
||||
if (!FindNextFileW (hFind, &findData))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -845,7 +844,7 @@ string getname (dirent *de)
|
|||
{
|
||||
nlassert (de != NULL);
|
||||
#ifdef NL_OS_WINDOWS
|
||||
return de->cFileName;
|
||||
return wideToUtf8(de->cFileName);
|
||||
#else
|
||||
return de->d_name;
|
||||
#endif // NL_OS_WINDOWS
|
||||
|
@ -1766,14 +1765,14 @@ std::string CFileContainer::getWindowsDirectory()
|
|||
nlwarning("not a ms windows platform");
|
||||
return "";
|
||||
#else
|
||||
char winDir[MAX_PATH];
|
||||
UINT numChar = ::GetWindowsDirectory(winDir, MAX_PATH);
|
||||
wchar_t winDir[MAX_PATH];
|
||||
UINT numChar = GetWindowsDirectoryW(winDir, MAX_PATH);
|
||||
if (numChar > MAX_PATH || numChar == 0)
|
||||
{
|
||||
nlwarning("Couldn't retrieve windows directory");
|
||||
return "";
|
||||
}
|
||||
return CPath::standardizePath(winDir);
|
||||
return CPath::standardizePath(wideToUtf8(winDir));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1789,18 +1788,18 @@ std::string CFileContainer::getApplicationDirectory(const std::string &appName,
|
|||
if (appPath.empty())
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
char buffer[MAX_PATH];
|
||||
wchar_t buffer[MAX_PATH];
|
||||
#ifdef CSIDL_LOCAL_APPDATA
|
||||
if (local)
|
||||
{
|
||||
SHGetSpecialFolderPathA(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE);
|
||||
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
SHGetSpecialFolderPathA(NULL, buffer, CSIDL_APPDATA, TRUE);
|
||||
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE);
|
||||
}
|
||||
appPath = CPath::standardizePath(buffer);
|
||||
appPath = CPath::standardizePath(wideToUtf8(buffer));
|
||||
#elif defined(NL_OS_MAC)
|
||||
appPath = CPath::standardizePath(getenv("HOME"));
|
||||
appPath += "/Library/Application Support/";
|
||||
|
@ -1918,7 +1917,7 @@ string CFile::getPath (const string &filename)
|
|||
bool CFile::isDirectory (const string &filename)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
DWORD res = GetFileAttributes(filename.c_str());
|
||||
DWORD res = GetFileAttributesW(utf8ToWide(filename));
|
||||
if (res == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
// nlwarning ("PATH: '%s' is not a valid file or directory name", filename.c_str ());
|
||||
|
@ -1941,7 +1940,7 @@ bool CFile::isDirectory (const string &filename)
|
|||
bool CFile::isExists (const string &filename)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
return (GetFileAttributes(filename.c_str()) != INVALID_FILE_ATTRIBUTES);
|
||||
return GetFileAttributesW(utf8ToWide(filename)) != INVALID_FILE_ATTRIBUTES;
|
||||
#else // NL_OS_WINDOWS
|
||||
struct stat buf;
|
||||
return stat (filename.c_str (), &buf) == 0;
|
||||
|
@ -2013,7 +2012,7 @@ uint32 CFile::getFileSize (const std::string &filename)
|
|||
{
|
||||
#if defined (NL_OS_WINDOWS)
|
||||
struct _stat buf;
|
||||
int result = _stat (filename.c_str (), &buf);
|
||||
int result = _wstat (utf8ToWide(filename), &buf);
|
||||
#elif defined (NL_OS_UNIX)
|
||||
struct stat buf;
|
||||
int result = stat (filename.c_str (), &buf);
|
||||
|
@ -2064,7 +2063,7 @@ uint32 CFile::getFileModificationDate(const std::string &filename)
|
|||
// Use the WIN32 API to read the file times in UTC
|
||||
|
||||
// create a file handle (this does not open the file)
|
||||
HANDLE h = CreateFile(fn.c_str(), 0, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
HANDLE h = CreateFileW(utf8ToWide(fn), 0, 0, NULL, OPEN_EXISTING, 0, 0);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
nlwarning("Can't get modification date on file '%s' : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
|
||||
|
@ -2134,7 +2133,7 @@ bool CFile::setFileModificationDate(const std::string &filename, uint32 modTime)
|
|||
// Use the WIN32 API to set the file times in UTC
|
||||
|
||||
// create a file handle (this does not open the file)
|
||||
HANDLE h = CreateFile(fn.c_str(), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
||||
HANDLE h = CreateFileW(utf8ToWide(fn), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
nlwarning("Can't set modification date on file '%s' (error accessing file) : %s", fn.c_str(), NLMISC::formatErrorMessage(NLMISC::getLastError()).c_str());
|
||||
|
@ -2219,7 +2218,7 @@ uint32 CFile::getFileCreationDate(const std::string &filename)
|
|||
|
||||
#if defined (NL_OS_WINDOWS)
|
||||
struct _stat buf;
|
||||
int result = _stat (fn.c_str (), &buf);
|
||||
int result = _wstat(utf8ToWide(fn), &buf);
|
||||
#elif defined (NL_OS_UNIX)
|
||||
struct stat buf;
|
||||
int result = stat (fn.c_str (), &buf);
|
||||
|
@ -2353,7 +2352,7 @@ static bool CopyMoveFile(const std::string &dest, const std::string &src, bool c
|
|||
else
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
if (MoveFile(ssrc.c_str(), sdest.c_str()) == 0)
|
||||
if (MoveFileW(utf8ToWide(ssrc), utf8ToWide(sdest)) == 0)
|
||||
{
|
||||
sint lastError = NLMISC::getLastError();
|
||||
nlwarning ("PATH: CopyMoveFile error: can't link/move '%s' into '%s', error %u (%s)",
|
||||
|
@ -2456,7 +2455,7 @@ bool CFile::moveFile(const std::string &dest, const std::string &src)
|
|||
bool CFile::createDirectory(const std::string &filename)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
return _mkdir(filename.c_str())==0;
|
||||
return _wmkdir(utf8ToWide(filename))==0;
|
||||
#else
|
||||
// Set full permissions....
|
||||
return mkdir(filename.c_str(), 0xFFFF)==0;
|
||||
|
@ -2677,11 +2676,13 @@ bool CPath::isAbsolutePath(const std::string &path)
|
|||
bool CFile::setRWAccess(const std::string &filename)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
wchar_t *wideFile = utf8ToWide(filename);
|
||||
|
||||
// if the file exists and there's no write access
|
||||
if (_access (filename.c_str(), 00) == 0 && _access (filename.c_str(), 06) == -1)
|
||||
if (_waccess (wideFile, 00) == 0 && _waccess (wideFile, 06) == -1)
|
||||
{
|
||||
// try to set the read/write access
|
||||
if (_chmod (filename.c_str(), _S_IREAD | _S_IWRITE) == -1)
|
||||
if (_wchmod (wideFile, _S_IREAD | _S_IWRITE) == -1)
|
||||
{
|
||||
if (INelContext::getInstance().getAlreadyCreateSharedAmongThreads())
|
||||
{
|
||||
|
|
|
@ -315,19 +315,19 @@ string CSystemUtils::getRegKey(const string &Entry)
|
|||
#ifdef NL_OS_WINDOWS
|
||||
HKEY hkey;
|
||||
|
||||
if(RegOpenKeyEx(HKEY_CURRENT_USER, RootKey.c_str(), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER, utf8ToWide(RootKey), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwType = 0L;
|
||||
DWORD dwSize = KeyMaxLength;
|
||||
unsigned char Buffer[KeyMaxLength];
|
||||
|
||||
if(RegQueryValueEx(hkey, Entry.c_str(), NULL, &dwType, Buffer, &dwSize) != ERROR_SUCCESS)
|
||||
if (RegQueryValueExW(hkey, utf8ToWide(Entry), NULL, &dwType, Buffer, &dwSize) != ERROR_SUCCESS)
|
||||
{
|
||||
nlwarning("Can't get the reg key '%s'", Entry.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = (char*)Buffer;
|
||||
ret = wideToUtf8(Buffer);
|
||||
}
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
@ -346,10 +346,12 @@ bool CSystemUtils::setRegKey(const string &ValueName, const string &Value)
|
|||
HKEY hkey;
|
||||
DWORD dwDisp;
|
||||
|
||||
char nstr[] = { 0x00 };
|
||||
if (RegCreateKeyExA(HKEY_CURRENT_USER, RootKey.c_str(), 0, nstr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
|
||||
wchar_t nstr[] = { 0x00 };
|
||||
if (RegCreateKeyExW(HKEY_CURRENT_USER, utf8ToWide(RootKey), 0, nstr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
|
||||
{
|
||||
if (RegSetValueExA(hkey, ValueName.c_str(), 0L, REG_SZ, (const BYTE *)Value.c_str(), (DWORD)(Value.size())+1) == ERROR_SUCCESS)
|
||||
ucstring utf16Value = ucstring::makeFromUtf8(Value);
|
||||
DWORD size = (utf16Value.length() + 1) * 2;
|
||||
if (RegSetValueExW(hkey, utf8ToWide(ValueName), 0L, REG_SZ, (const BYTE *)utf16Value.c_str(), size) == ERROR_SUCCESS)
|
||||
res = true;
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
@ -453,7 +455,7 @@ static void EnumerateUsingDXGI(IDXGIFactory *pDXGIFactory)
|
|||
{
|
||||
SAdapter adapter;
|
||||
adapter.id = index;
|
||||
adapter.name = ucstring((ucchar*)desc.Description).toUtf8();
|
||||
adapter.name = wideToUtf8(desc.Description);
|
||||
adapter.memory = desc.DedicatedVideoMemory / 1024;
|
||||
adapter.found = true;
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ namespace NLMISC
|
|||
void CWin32Util::localizeWindow(HWND wnd)
|
||||
{
|
||||
if (!wnd) return;
|
||||
int textLength = GetWindowTextLength(wnd);
|
||||
sint textLength = GetWindowTextLengthW(wnd);
|
||||
if (textLength > 0)
|
||||
{
|
||||
std::vector<char> str(textLength + 1);
|
||||
GetWindowText(wnd, &str[0], textLength + 1);
|
||||
std::string winText(str.begin(), str.end() - 1);
|
||||
wchar_t str[1024];
|
||||
GetWindowTextW(wnd, str, 1024);
|
||||
std::string winText = wideToUtf8(str);
|
||||
if (CI18N::hasTranslation(winText))
|
||||
{
|
||||
SetWindowTextW(wnd, (const WCHAR *) CI18N::get(winText).c_str());
|
||||
|
|
|
@ -198,7 +198,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
string str = ucs.toUtf8();
|
||||
nlassert (cwd->Log != NULL);
|
||||
ICommand::expand (str, *cwd->Log);
|
||||
SendMessage (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)str.c_str());
|
||||
SendMessageW (cwd->_HInputEdit, WM_SETTEXT, (WPARAM)0, (LPARAM)wText);
|
||||
|
||||
SendMessage (cwd->_HInputEdit, EM_SETSEL, str.size(), str.size());
|
||||
|
||||
|
|
|
@ -277,10 +277,10 @@ uint64 CWinThread::getCPUMask()
|
|||
|
||||
std::string CWinThread::getUserName()
|
||||
{
|
||||
char userName[512];
|
||||
wchar_t userName[512];
|
||||
DWORD size = 512;
|
||||
GetUserName (userName, &size);
|
||||
return (const char*)userName;
|
||||
GetUserNameW (userName, &size);
|
||||
return wideToUtf8(userName);
|
||||
}
|
||||
|
||||
// **** Process
|
||||
|
@ -333,10 +333,10 @@ class CPSAPILib
|
|||
{
|
||||
public:
|
||||
typedef BOOL (WINAPI *EnumProcessesFunPtr)(DWORD *lpidProcess, DWORD cb, DWORD *cbNeeded);
|
||||
typedef DWORD (WINAPI *GetModuleFileNameExAFunPtr)(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);
|
||||
typedef DWORD (WINAPI *GetModuleFileNameExWFunPtr)(HANDLE hProcess, HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
|
||||
typedef BOOL (WINAPI *EnumProcessModulesFunPtr)(HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded);
|
||||
EnumProcessesFunPtr EnumProcesses;
|
||||
GetModuleFileNameExAFunPtr GetModuleFileNameExA;
|
||||
GetModuleFileNameExWFunPtr GetModuleFileNameExW;
|
||||
EnumProcessModulesFunPtr EnumProcessModules;
|
||||
public:
|
||||
CPSAPILib();
|
||||
|
@ -353,7 +353,7 @@ CPSAPILib::CPSAPILib()
|
|||
_LoadFailed = false;
|
||||
_PSAPILibHandle = NULL;
|
||||
EnumProcesses = NULL;
|
||||
GetModuleFileNameExA = NULL;
|
||||
GetModuleFileNameExW = NULL;
|
||||
EnumProcessModules = NULL;
|
||||
}
|
||||
|
||||
|
@ -381,10 +381,10 @@ bool CPSAPILib::init()
|
|||
return false;
|
||||
}
|
||||
EnumProcesses = (EnumProcessesFunPtr) GetProcAddress(_PSAPILibHandle, "EnumProcesses");
|
||||
GetModuleFileNameExA = (GetModuleFileNameExAFunPtr) GetProcAddress(_PSAPILibHandle, "GetModuleFileNameExA");
|
||||
GetModuleFileNameExW = (GetModuleFileNameExWFunPtr) GetProcAddress(_PSAPILibHandle, "GetModuleFileNameExW");
|
||||
EnumProcessModules = (EnumProcessModulesFunPtr) GetProcAddress(_PSAPILibHandle, "EnumProcessModules");
|
||||
if (!EnumProcesses ||
|
||||
!GetModuleFileNameExA ||
|
||||
!GetModuleFileNameExW ||
|
||||
!EnumProcessModules
|
||||
)
|
||||
{
|
||||
|
@ -453,12 +453,12 @@ bool CWinProcess::enumProcessModules(uint32 processId, std::vector<std::string>
|
|||
}
|
||||
moduleNames.clear();
|
||||
std::vector<std::string> resultModuleNames;
|
||||
char moduleName[MAX_PATH + 1];
|
||||
wchar_t moduleName[MAX_PATH + 1];
|
||||
for (uint m = 0; m < prcModules.size(); ++m)
|
||||
{
|
||||
if (PSAPILib.GetModuleFileNameExA(hProcess, prcModules[m], moduleName, MAX_PATH))
|
||||
if (PSAPILib.GetModuleFileNameExW(hProcess, prcModules[m], moduleName, MAX_PATH))
|
||||
{
|
||||
moduleNames.push_back(moduleName);
|
||||
moduleNames.push_back(wideToUtf8(moduleName));
|
||||
}
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
|
@ -563,7 +563,7 @@ public:
|
|||
PROCESS_INFORMATION processInfo;
|
||||
STARTUPINFO startupInfo = {0};
|
||||
startupInfo.cb = sizeof(STARTUPINFO);
|
||||
if (CreateProcess(programName.c_str(), const_cast<LPTSTR>(arguments.c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
|
||||
if (CreateProcessW(programName.c_str(), const_cast<LPTSTR>(arguments.c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
|
||||
{
|
||||
WatchTask = new CProcessWatchTask(processInfo.hProcess);
|
||||
WatchThread = IThread::create(WatchTask);
|
||||
|
|
|
@ -3937,13 +3937,15 @@ public:
|
|||
s += getSystemInformation();
|
||||
|
||||
string progname;
|
||||
char name[1024] = "";
|
||||
std::string moduleName;
|
||||
#ifdef NL_OS_WINDOWS
|
||||
GetModuleFileName (NULL, name, 1023);
|
||||
wchar_t name[1024];
|
||||
GetModuleFileNameW(NULL, name, 1023);
|
||||
moduleName = wideToUtf8(name);
|
||||
#else
|
||||
// TODO for Linux
|
||||
#endif
|
||||
progname = CFile::getFilename(name);
|
||||
progname = CFile::getFilename(moduleName);
|
||||
progname += " ";
|
||||
progname += "Statistic Report";
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ bool CXDPFileReader::init(const std::string &sFilename, sint32 nLowerBound, sint
|
|||
{
|
||||
// First open the file with a normal function
|
||||
#ifdef NL_OS_WINDOWS
|
||||
int fd = _open(sFilename.c_str(), _O_BINARY | _O_RDONLY);
|
||||
int fd = _wopen(utf8ToWide(sFilename), _O_BINARY | _O_RDONLY);
|
||||
#else
|
||||
int fd = open(sFilename.c_str(), O_RDONLY);
|
||||
#endif
|
||||
|
|
|
@ -84,7 +84,7 @@ static void setPermanentBanFileMarker(const std::string &path, bool on)
|
|||
// simply touch a file
|
||||
COFile f(path);
|
||||
#ifdef NL_OS_WINDOWS
|
||||
SetFileAttributes(path.c_str(), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
|
||||
SetFileAttributesW(utf8ToWide(path), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
|
||||
#endif
|
||||
}
|
||||
catch(const EStream &e)
|
||||
|
|
Loading…
Reference in a new issue