gneash
gneash

Reputation: 99

How to check if the currently logged on user is using roaming profile?

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

Is there any .net framework library that can help?

Upvotes: 3

Views: 3909

Answers (2)

Ethan Wang
Ethan Wang

Reputation: 98

    [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
        }
    }

Upvotes: 2

Robert Horvick
Robert Horvick

Reputation: 4036

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.

Upvotes: 3

Related Questions