获取桌面路径在C#中的所有管理员 [英] Get desktop path for all administrators in C#

查看:140
本文介绍了获取桌面路径在C#中的所有管理员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为系统中的所有主机创建我的应用程序的桌面快捷方式。
我使用下面的代码获取用户列表。

I need to create desktop shortcuts to my app for all administratos in the system. I'm using the following code to get user list.

        var identifier = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
        GroupPrincipal group = GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Machine), identifier.Value);

        foreach (Principal principal in group.Members)
        {
            Console.WriteLine(principal.Name);
        }

我需要以某种方式获取每个用户的桌面路径。你能给我建议我的解决方案吗?非常感谢。

I need somehow to get desktop path for each user. Could you suggest me solution? Many thanks.

推荐答案

你需要pinvoke SHGetFolderLocation函数(http://msdn.microsoft.com/en- us / library / bb762180.aspx),它允许你传入代表你感兴趣的用户的访问令牌。

You'll want to pinvoke the SHGetFolderLocation function (http://msdn.microsoft.com/en-us/library/bb762180.aspx) which allows you to pass in an access token that represents the user you're interested in.

不知道如何有困难。

这篇关于获取桌面路径在C#中的所有管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆