問(wèn)題描述
我正在開(kāi)發(fā)一個(gè)分區(qū)磁盤程序,我需要管理員權(quán)限才能讀取\\.\PhysicalDrive0
.
I am developing a partition disk program, and for me to read the \\.\PhysicalDrive0
I need admin rights.
我想知道程序是否有可能在運(yùn)行時(shí)獲得管理員權(quán)限?有沒(méi)有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?
我想這樣做是因?yàn)槲蚁M绦騼H在讀取/寫入磁盤時(shí)以管理員權(quán)限執(zhí)行.出于安全原因,我不希望該程序始終以管理員權(quán)限執(zhí)行,因?yàn)橛腥丝赡軙?huì)在某個(gè)模塊中發(fā)現(xiàn)錯(cuò)誤(例如堆棧或堆溢出)并以 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.
推薦答案
在進(jìn)程開(kāi)始后,您將無(wú)法獲得提升的權(quán)限.您的選擇是:
You cannot acquire elevated privileges after the process has started. Your options are:
- 將需要提升權(quán)限的應(yīng)用程序部分放入一個(gè)單獨(dú)的進(jìn)程中,并使用
requireAdministrator
進(jìn)行說(shuō)明. - 將需要提升權(quán)限的應(yīng)用程序部分作為進(jìn)程外 COM 對(duì)象運(yùn)行.
這篇關(guān)于可執(zhí)行文件是否可以要求管理員權(quán)限?(Windows 7的)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!