問題描述
我正在開發(fā)一個分區(qū)磁盤程序,我需要管理員權(quán)限才能讀取\\.\PhysicalDrive0
.
I am developing a partition disk program, and for me to read the \\.\PhysicalDrive0
I need admin rights.
我想知道程序是否有可能在運行時獲得管理員權(quán)限?有沒有win api?
I am wondering if it is possible, in the run time, for the program to gain admin rights? Is there any win api for that?
我想這樣做是因為我希望程序僅在讀取/寫入磁盤時以管理員權(quán)限執(zhí)行.出于安全原因,我不希望該程序始終以管理員權(quán)限執(zhí)行,因為有人可能會在某個模塊中發(fā)現(xiàn)錯誤(例如堆?;蚨岩绯?并以 adm 身份執(zhí)行任意命令.
I want to do that because I want the program to execute with admin rights only when it is reading/writing the disk. For security reasons, I don't want the program to execute all the time with admin rights, because someone could find a bug (stack or heap overflow for example) in some module and execute arbitrary commands as adm.
推薦答案
在進程開始后,您將無法獲得提升的權(quán)限.您的選擇是:
You cannot acquire elevated privileges after the process has started. Your options are:
- 將需要提升權(quán)限的應(yīng)用程序部分放入一個單獨的進程中,并使用
requireAdministrator
進行說明. - 將需要提升權(quán)限的應(yīng)用程序部分作為進程外 COM 對象運行.
這篇關(guān)于可執(zhí)行文件是否可以要求管理員權(quán)限?(Windows 7的)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!