Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Platform/Windows/Users.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
6#include <Windows.h>
7
8#include "Exception.h"
9
10#include "Users.h"
11
12using namespace Stroika::Foundation;
13using namespace Stroika::Foundation::Execution;
15
18
19/*
20 ********************************************************************************
21 *********************** Platform::Windows::SID22UserName ***********************
22 ********************************************************************************
23 */
24String Platform::Windows::SID22UserName (PSID sid)
25{
26 SID_NAME_USE iUse{};
27 SDKChar name[1024];
28 SDKChar domain[1024];
29 DWORD nameLen{static_cast<DWORD> (Memory::NEltsOf (name))};
30 DWORD domainLen{static_cast<DWORD> (Memory::NEltsOf (domain))};
31 ThrowIfZeroGetLastError (::LookupAccountSid (nullptr, sid, name, &nameLen, domain, &domainLen, &iUse));
32 if (domainLen == 0) {
33 return String::FromSDKString (name);
34 }
35 else {
36 return String::FromSDKString (name) + "@"sv + String::FromSDKString (domain);
37 }
38}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
conditional_t< qTargetPlatformSDKUseswchar_t, wchar_t, char > SDKChar
Definition SDKChar.h:71