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

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

有帮助吗?

解决方案

我认为唯一的方法是调用Win32 shell函数 GetProfileType 。您需要使用P / Invoke进行调用,然后检查PT_ROAMING的pdwFlags参数的out值(值为2)。

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

BOOL WINAPI GetProfileType(      
    DWORD *pdwFlags
);

创建一个并不难。

其他提示

    [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
        }
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top