如何使用标准用户检索连接点或符号链接的目标

发布于 2024-08-21 14:58:11 字数 255 浏览 7 评论 0原文

我试图获取程序中连接的目标,但我设法做到这一点的唯一方法是:

  1. 请求备份权限
  2. p-invoke CreateFile 使用特殊参数来获取文件/目录的句柄。
  3. DeviceIoControl 调用以获取目标。

第一步不适用于普通用户帐户,因为他们没有备份权限,而且我不想每次执行此操作时都获得 UAC 用户同意窗口。

我认为这是可行的,因为正常的“dir /A:L”命令可以解析链接的目标。

I am trying to get the target of a junction in my program, but the only way I managed do it is:

  1. Requesting Backup privileges
  2. p-invoke CreateFile with special parameters to get a handle to the file/dir.
  3. DeviceIoControl call to the get the target.

The 1st step will not work with normal user accounts, because they have no Backup privileges, and I don't want to get the UAC User Consent window every time I do this.

I think this is doable somehow, because a normal "dir /A:L" command resolves the target of the links.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲歌长辞 2024-08-28 14:58:11

我认为 stackoverflow 中的这个答案会对您有所帮助?
如何以编程方式访问Windows 符号链接的目标路径?
应该可以通过 ac# 程序中的 DllImport 属性包含对该函数的引用。

所需的句柄可从 FileStream 实例。有点有趣的是它被标记为过时,但也许警告说明了您还可以做什么。

I think that this answer in stackoverflow would help you?
How do I programmatically access the target path of a windows symbolic link?
It should be possible to include a reference to the function via DllImport Attribute in a c# program.

The required handle is obtainable from the a FileStream instance. Somewhat funny that it is marked as obsolete, but maybe the warning states what else you can do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文