Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何检查当前登录的用户是否使用漫游配置文件?_C#_.net_Environment - Fatal编程技术网

C# 如何检查当前登录的用户是否使用漫游配置文件?

C# 如何检查当前登录的用户是否使用漫游配置文件?,c#,.net,environment,C#,.net,Environment,如何检查当前用户是否正在使用漫游配置文件 是否有任何.net framework库可以提供帮助?我认为唯一的方法是调用Win32 shell函数。您需要使用P/Invoke进行调用,然后检查PT_漫游的pdwFlags参数的out值(其值为2) 我在pinvoke.net上没有看到此函数的签名示例,但签名非常简单: BOOL WINAPI GetProfileType( DWORD *pdwFlags ); 创建一个并不困难。@Bubbafat:具有漫游配置文件的用户在默认

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


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

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

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

BOOL WINAPI GetProfileType(      
    DWORD *pdwFlags
);

创建一个并不困难。

@Bubbafat:具有漫游配置文件的用户在默认情况下没有安装权限,这是真的吗?那么如何设置这些权限呢?
    [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
        }
    }