本文介绍了dll 请求的执行级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在开发的 WinForms 应用程序.有一小部分功能需要在 Vista/Win7 中以管理员身份运行.我了解如何为清单中的应用程序设置 requestsExecutionLevel.诀窍是,我不想要求用户以管理员身份运行整个应用程序,而只是其中的一部分.所以我想让大部分功能作为Invoker 运行.

I've got a WinForms application that I am working on. There is one small piece of functionality that needs to be run as an administrator in Vista/Win7. I understand how I can set the requestedExecutionLevel for the application in the manifest. The trick is, I don't want to require the user to run the entire application as an administrator, just one part of it. So I would like to have most of the functionality run asInvoker.

如果我将管理功能放在 dll 中,是否可以将其标记为 requireAdministrator?我尝试使用 MT 向 dll 添加清单,但这似乎不起作用.我需要做什么?

If I put the admin functionality in a dll, is there a way to mark it as requireAdministrator? I tried to use MT to add a manifest to the dll, but that didn't seem to work. What do I need to do?

推荐答案

不,没有办法根据 DLL 来区分 DLL 上的应用程序的执行级别.这是一个过程范围的设置.您必须调用应用程序中的另一个进程,该进程以提升的权限运行该 DLL 中的代码.

No there is no way to differentiate the execution level of an application on a DLL by DLL basis. This is a process wide setting. You'd have to invoke another process within your application that runs the code in that DLL with elevated privs.

不过,您可以选择使用 rundll 或 rundll32 程序直接运行 DLL.这是一个独立的 Windows 程序,旨在加载和运行特定的 DLL.您可以提升 rundll 进程并获得所需的隔离.

One option you do have though is to use either the rundll or rundll32 program to run the DLL directly. This is a standalone windows program designed to load and run a particular DLL. You could elevate the rundll process and get the isolation you desire.

谷歌搜索 rundll 会给你很多关于如何使用它的建议:).

Googling for rundll will give you plenty of advice on how to use it :).

这篇关于dll 请求的执行级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 01:42