Have in memory two processes of the same program, and maybe have them communicate with a pipe. The user starts the program normally without elevated privileges. Once the elevation is required you start the same program with ShellExecuteEx and verb "runas". This "runas" verb will cause UAC prompt.
If you need elevated privileges only once for the whole duration of the original process, then you can pass some parameters to the elevated process, and be done with it. But if you need elevated process to perform several actions, at different times, then you have to have a pipe open between two processes, to send data to the elevated process. This way you have UAC prompt only once, but do stuff that need elevation any time you need.
发布评论
评论(1)
在内存中,同一程序的两个过程,也许让它们与管道通信。用户正常启动程序而没有提高特权。一旦需要高程,您就可以使用
shellexecuteex
和动词“ runas”开始相同的程序。这个“ runas”动词将导致UAC提示。如果您在原始过程的整个过程中仅需要一次提高特权,则可以将一些参数传递到高架过程中,然后使用它。但是,如果您需要提高过程才能在不同的时间执行多个操作,那么您必须在两个过程之间打开管道,以将数据发送到提升过程。这样,您只需提示一次UAC,但是随时需要进行高程的工作。
Have in memory two processes of the same program, and maybe have them communicate with a pipe. The user starts the program normally without elevated privileges. Once the elevation is required you start the same program with
ShellExecuteEx
and verb "runas". This "runas" verb will cause UAC prompt.If you need elevated privileges only once for the whole duration of the original process, then you can pass some parameters to the elevated process, and be done with it. But if you need elevated process to perform several actions, at different times, then you have to have a pipe open between two processes, to send data to the elevated process. This way you have UAC prompt only once, but do stuff that need elevation any time you need.