From ce6a723ec6d192121a5e99d9876e156830a82f9e Mon Sep 17 00:00:00 2001 From: san Date: Mon, 16 Feb 2009 06:51:53 +0000 Subject: [PATCH] Processing Unicode string returned by Win32 API correctly --- src/SUIT/SUIT_LicenseDlg.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SUIT/SUIT_LicenseDlg.cxx b/src/SUIT/SUIT_LicenseDlg.cxx index 4faafba13..359436d9a 100755 --- a/src/SUIT/SUIT_LicenseDlg.cxx +++ b/src/SUIT/SUIT_LicenseDlg.cxx @@ -118,15 +118,16 @@ void SUIT_LicenseDlg::onAgree() { QString env; #ifdef WIN32 - DWORD aLen=1024; - char aStr[1024]; + DWORD aLen=1024; + wchar_t aStr[1024]; HANDLE aToken=0; HANDLE hProcess = GetCurrentProcess(); OpenProcessToken(hProcess,TOKEN_QUERY,&aToken); if( ! GetUserProfileDirectory( aToken, aStr, &aLen ) ) reject(); - env = aStr; + if ( aLen > 0 ) + env = QString::fromWCharArray(aStr, aLen); #else if( ! ::getenv( "HOME" ) ) reject(); -- 2.39.2