mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-31 17:11:02 +03:00
use api rather than cmd to retrieve active user name to solve
non-English problem
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user