use api rather than cmd to retrieve active user name to solve

non-English problem
This commit is contained in:
rustdesk
2021-04-09 09:58:50 +08:00
parent 0503a4d5b6
commit de4bb684af
3 changed files with 40 additions and 2 deletions

View File

@@ -363,4 +363,21 @@ extern "C"
{
SHAddToRecentDocs(SHARD_PATHW, path);
}
} // end of extern "C"
uint32_t get_active_user(PWSTR bufin, uint32_t nin)
{
uint32_t nout = 0;
auto id = WTSGetActiveConsoleSessionId();
PWSTR buf = NULL;
DWORD n = 0;
if (WTSQuerySessionInformationW(NULL, id, WTSUserName, &buf, &n))
{
if (buf) {
nout = min(nin, n);
memcpy(bufin, buf, nout);
WTSFreeMemory(buf);
}
}
return nout;
}
} // end of extern "C"