在Delphi中开发具有管理员权限的应用程序 [英] Developing Apps with Administrator Rights in Delphi

查看:489
本文介绍了在Delphi中开发具有管理员权限的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7下使用D2010来编写似乎需要管理员权限的应用程序(我认为是因为它使用COM与第三方.exe进行通信,这也需要管理员权限)。



我已经根据需要添加了清单资源,但是当我尝试从IDE调试应用程序时,它会报告


无法创建进程
请求操作需要
标高


...它不会运行。如果我以管理员身份运行Delphi,那么我的应用程序运行正常,但这感觉就像一个危险的暴力方法,特别是因为我开发的大多数应用程序都不需要管理员权限。


解决方案

有没有办法让Delphi在运行我的应用程序时提示提升, div>

没有,它也不适用于VS:



http://stackoverflow.com/questions/3265787/how-doi-i -debug-an-process-as-elevated-with-visual-studio-2008-sp1-on-windows-7



我想你可以运行远程调试器提升并使用远程调试来附加IDE。



它不起作用,因为进程作为另一个用户运行(或使用另一个用户令牌)。



IDE正在尝试运行调试过程使用CreateProcess,并且当应用程序需要elavation失败,更多的细节可以在这篇文章中找到:



http://www.codeproject.com/KB/vista-security/UAC__The_Definitive_Guide.aspx



RAD Studio可以使用ShellExecute与runas动词运行应用程序,但这仍然不能解决其他用户上下文下的调试过程。



换句话说:升级的过程只能由精简的调试器进行调试。



编辑:



Delphi XE2 IDE是32位,只能通过远程调试器(这是用户聪明地隐藏)来调试64位应用程序。



我猜Embarcadero可以以类似的方式调试升级的应用程序。


I'm using D2010 under Windows 7 to write an app that seems to require admin rights (I think because it uses COM to communicate with a third party .exe, which also requires admin rights).

I've added the manifest resource as required, but when I try to debug the app from the IDE, it reports

"Unable to create process. The requested operation requires elevation"

...and it won't run. If I run Delphi as administrator, then my app runs correctly, but this feels like a dangerous brute force approach, especially as most of the apps I develop don't need admin privileges.

Is there any way of getting Delphi to prompt for elevation just when I run my app, rather than having the whole IDE run elevated?

解决方案

There is none, it also doesn't work for VS:

http://stackoverflow.com/questions/3265787/how-do-i-debug-an-process-as-elevated-with-visual-studio-2008-sp1-on-windows-7

I guess you could run the remote debugger elevated and attach the IDE using remote debugging though.

It doesn't work, because the process is running as another user (or using another user token).

The IDE is trying to run the debugging process using CreateProcess and that fails when the application requires elavation, more details can be found in this article:

http://www.codeproject.com/KB/vista-security/UAC__The_Definitive_Guide.aspx

RAD Studio could run the application using ShellExecute with the "runas" verb, but this still doesn't solve the "debugging process under other user context" issue.

In other words: An elevated process can only be debugged by an elavated debugger.

Edit:

The Delphi XE2 IDE is 32-Bit and can debug 64-Bit applications only through the remote debugger (which is cleverly hidden from the user).

I guess Embarcadero could make it possible to debug elevated applications in a similar fashion.

这篇关于在Delphi中开发具有管理员权限的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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