在《windows核心编程》中说道的提高进程权限只有在进程边界(boundary)的时候才能提升,那么我看到用 ShellExecuteEx改变进程的权限,这个函数是重新启动进程吗? 请教!

解决方案 »

  1.   

    ShellExecuteEx不能改变运行的进程权限,只能以高权限重新启动程序。微软具体代码:
    #include "stdafx.h"
    #include "windows.h"
    #include "shellapi.h"
    int _tmain(int argc, _TCHAR* argv[])
    {
          SHELLEXECUTEINFO shExecInfo;      shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);      shExecInfo.fMask = NULL;
          shExecInfo.hwnd = NULL;
          shExecInfo.lpVerb = L"runas";
          shExecInfo.lpFile = L"notepad.exe";
          shExecInfo.lpParameters = NULL;
          shExecInfo.lpDirectory = NULL;
          shExecInfo.nShow = SW_MAXIMIZE;
          shExecInfo.hInstApp = NULL;      ShellExecuteEx(&shExecInfo);      return 0;
    }
      

  2.   

    那<<Windows 核心编程>> 中有一句关于这个权限提升的: Windows allows privileges elevation only on a process  boundary 这句怎么去理解? 如果不是通过重新启动进程的话!