Question

How can I check if the current user is using roaming profile?

Is there any .net framework library that can help?

Was it helpful?

Solution

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

I don't 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 hard.

OTHER TIPS

    [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
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top