3

如何检查当前用户是否正在使用漫游配置文件?

是否有任何 .net 框架库可以提供帮助?

4

2 回答 2

3

我相信这样做的唯一方法是调用 Win32 shell 函数GetProfileType。您需要使用 P/Invoke 进行调用,然后检查 PT_ROAMING 的 pdwFlags 参数的输出值(其值为 2)。

我在 pinvoke.net 上没有看到此函数的示例签名,但签名如此简单:

BOOL WINAPI GetProfileType(      
    DWORD *pdwFlags
);

创建一个并不难。

于 2009-07-29T14:12:17.807 回答
2
    [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
        }
    }
于 2013-05-23T09:36:06.320 回答