ShellExecuteEx 以管理员权限启动进程

#include 
#include 
#include 

int main()
{
  SHELLEXECUTEINFO se;
  memset(&se, 0, sizeof(SHELLEXECUTEINFO));
  se.cbSize = sizeof(SHELLEXECUTEINFO);
  se.lpVerb = L"runas";
  se.lpFile = L"cmd.exe"; //要打开的进程路径
  se.lpParameters = L"Administrator" //管理员权限
  se.nShow = SW_HIDE;//打开的进程不显示界面
  se.fMask = 0;//不要进程句柄
  if(ShellExecuteEx(&se))
  {
     std::cout << "successfully"<

 

你可能感兴趣的:(windwos,C/C++)