How to check if the user who is currently logged in uses a roaming profile?

How to check if the current user is using a roaming profile?

Is there any framework.net library that can help?

+3
source share
2 answers

I believe the only way to do this is to call the Win32 shell function GetProfileType . You will need to use P / Invoke to make the call, and then check the out value of the pdwFlags parameter for PT_ROAMING (which has a value of 2).

I do not see a sample signature for this function on pinvoke.net, but with such a simple signature:

BOOL WINAPI GetProfileType(      
    DWORD *pdwFlags
);

Creating one would not be difficult.

+3
    [DllImport("Userenv.dll", EntryPoint = "GetProfileType", SetLastError = true, CharSet = CharSet.Auto)]
    public static extern bool GetProfileType(ref uint pdwflags);

    [Flags]
    enum Win32ProfileType : uint { 
        Local=0x00,
        Temporary=0x01,
        Roaming=0x02,
        Mandatory=0x04
    }


    public void SomeTest()
    {
        uint type = 0;
        if (GetProfileType(ref type)) {
            //todo
        }
    }
+2

Source: https://habr.com/ru/post/1713853/


All Articles