Click here to Skip to main content
15,902,032 members
Home / Discussions / Windows Development
   

Windows Development

 
GeneralRe: select() slowness Pin
Gisle Vanem29-Jun-22 23:51
Gisle Vanem29-Jun-22 23:51 
GeneralRe: select() slowness Pin
Dave Kreskowiak30-Jun-22 4:28
mveDave Kreskowiak30-Jun-22 4:28 
GeneralRe: select() slowness Pin
Gisle Vanem30-Jun-22 8:03
Gisle Vanem30-Jun-22 8:03 
GeneralRe: select() slowness Pin
Dave Kreskowiak30-Jun-22 8:12
mveDave Kreskowiak30-Jun-22 8:12 
GeneralRe: select() slowness Pin
Gerry Schmitz30-Jun-22 8:22
mveGerry Schmitz30-Jun-22 8:22 
GeneralRe: select() slowness Pin
Gisle Vanem30-Jun-22 8:51
Gisle Vanem30-Jun-22 8:51 
GeneralRe: select() slowness Pin
k505430-Jun-22 11:18
mvek505430-Jun-22 11:18 
GeneralRe: select() slowness Pin
Gerry Schmitz2-Jul-22 7:12
mveGerry Schmitz2-Jul-22 7:12 
AnswerRe: select() slowness Pin
Eddy Vluggen2-Jul-22 4:32
professionalEddy Vluggen2-Jul-22 4:32 
AnswerRe: select() slowness Pin
Randor 20-Jul-22 2:37
professional Randor 20-Jul-22 2:37 
QuestionWhat does MS mean by the words "MinimalVisualStudioVersion" found in .sln files? Pin
RedDk15-Dec-21 12:14
RedDk15-Dec-21 12:14 
AnswerRe: What does MS mean by the words "MinimalVisualStudioVersion" found in .sln files? Pin
Randor 22-Dec-21 6:52
professional Randor 22-Dec-21 6:52 
QuestionBinding Pin
michaelbarb6-Dec-21 5:50
michaelbarb6-Dec-21 5:50 
AnswerRe: Binding Pin
Richard MacCutchan6-Dec-21 6:16
mveRichard MacCutchan6-Dec-21 6:16 
AnswerRe: Binding Pin
Gerry Schmitz6-Dec-21 6:23
mveGerry Schmitz6-Dec-21 6:23 
AnswerRe: Binding Pin
Samir Ibrahim4-Mar-22 21:37
Samir Ibrahim4-Mar-22 21:37 
GeneralRe: Binding Pin
Eddy Vluggen5-Mar-22 4:14
professionalEddy Vluggen5-Mar-22 4:14 
GeneralRe: Binding Pin
Samir Ibrahim6-Mar-22 21:32
Samir Ibrahim6-Mar-22 21:32 
GeneralRe: Binding Pin
RobertSF5-Mar-22 6:14
professionalRobertSF5-Mar-22 6:14 
GeneralRe: Binding Pin
Samir Ibrahim6-Mar-22 21:09
Samir Ibrahim6-Mar-22 21:09 
GeneralRe: Binding Pin
RedDk5-Mar-22 10:21
RedDk5-Mar-22 10:21 
QuestionBatch file - If statement findstr Pin
User 1536543221-Oct-21 9:11
User 1536543221-Oct-21 9:11 
AnswerRe: Batch file - If statement findstr Pin
Dave Kreskowiak21-Oct-21 12:09
mveDave Kreskowiak21-Oct-21 12:09 
QuestionGetting the interactive user's display language from a service Pin
Daniel Pfeffer25-Aug-21 4:24
professionalDaniel Pfeffer25-Aug-21 4:24 
AnswerRe: Getting the interactive user's display language from a service Pin
Randor 25-Aug-21 10:08
professional Randor 25-Aug-21 10:08 
Hi Daniel,

I think you are asking if it's possible to use the GetUserDefaultLCID function by impersonating the security context of a logged-on user. But I'm not sure if you know what that means. For example User1 (or Administrator) can execute apps as User2 and User3 which means all those user accounts will have 'interactive sessions'.

Also... you need to clarify which user language[^] you want to use. For example, some users might have MUI enabled[^] and have both Hebrew and English (or maybe a dozen).

If you really do want to look up the same information that the GetUserDefaultLCID function retrieves for a user that logged in via winlogon.exe from your system service then I can help you do that.

C++
#pragma comment(lib, "Secur32.lib")
#pragma comment(lib, "Advapi32.lib")

#include <iostream>
#include <windows.h>
#include <ntsecapi.h>
#include <sddl.h>

BOOL RegGetInternationaliations(const PSID p, const wchar_t name[], wchar_t *pOut, DWORD out_len)
{
    LPWSTR szSid = nullptr;
    BOOL bRet = FALSE;
    if (ConvertSidToStringSidW(p, &szSid))
    {
        HKEY k;
        constexpr DWORD size = 256;
        WCHAR buffer[size];
        wsprintf(buffer, L"%s\\Control Panel\\International", szSid);

        LSTATUS status = RegOpenKeyW(HKEY_USERS, buffer, &k);
        if (ERROR_SUCCESS == status)
        {
            status = RegGetValueW(k, NULL, name, RRF_RT_REG_SZ | RRF_ZEROONFAILURE, 0, pOut, &out_len);
            bRet = (ERROR_SUCCESS == status);

            RegCloseKey(k);
        }

        LocalFree(szSid);
    }

    return bRet;
}

INT main()
{
    DWORD lc = 0;
    DWORD status = 0;
    PLUID list = nullptr;

    LsaEnumerateLogonSessions(&lc, &list);
    for (DWORD i = 0; i < lc; i++)
    {
        PSECURITY_LOGON_SESSION_DATA pData;

        status = LsaGetLogonSessionData((PLUID)((INT_PTR)list + sizeof(LUID) * i), &pData);
        if (0 == status)
        {
            if (Interactive == pData->LogonType && (pData->UserFlags & LOGON_WINLOGON))
            {
                constexpr DWORD s = 256;
                WCHAR buffer[s];

                if (RegGetInternationaliations(pData->Sid, L"Locale", buffer, s))
                {
                    wprintf(L"Locale: %s\n", buffer);
                }
            }

            LsaFreeReturnBuffer(pData);
        }
    }
}


This will work from session 0 and does exactly the same thing as the GetUserDefaultLCID function for the logged in users. Those internationalization registry keys have been pretty much unchanged for 14 years (I think the last change there was 2006)

If you really do want to do this for ALL interactive sessions then remove the following:
C++
if (Interactive == pData->LogonType && (pData->UserFlags & LOGON_WINLOGON))


Also... if this isn't what you wanted... and what you really wanted was the currently selected MUI language[^] then let me know, it's an easy change.

I'm getting off now so I won't be back until tomorrow to read your response.

Best Wishes,
-David Delaune

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.