开发者

How to run CreateProcess as administrator? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

CreateProcess to run as administrator

How can I run a child process that requires elevation and wait?

How can I modify my current code here to make it run the CreateProcess as administrator?

  SECURITY_ATTRIBUTES secattr; 
  ZeroMemory(&secattr,sizeof(secattr));
  secattr.nLength = sizeof(secattr);
  secattr.bInheritHandle = TRUE;
  HANDLE rPipe, wPipe;

  //Create pipes to write and read data
  CreatePipe(&rPipe,&wPipe,&secattr,0);  
  STARTUPINFO sInfo; 
  ZeroMemory(&sInfo,sizeof(sInfo));
  PROCESS_INFORMATION pInfo; 
  ZeroMemory(&pInfo,sizeof(pInfo));
  sInfo.cb=sizeof(sInfo);
  sInfo.dwFlags=STARTF_USESTDHANDLES;
  sInfo.hStdInput=NULL; 
  sInfo.hStdOutput=wPipe; 
  sInfo.hStdError=wPipe;
  sInfo.wShowWindow;

  CString par开发者_JS百科ameterB = _T(" -format \"%h\" ") + pictureName;  
  CString parameterA = mycustompath + _T("identify.exe");

  if (CreateProcess(parameterA.GetBuffer(), parameterB.GetBuffer(),0,0,TRUE,
          NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo))
          {
            WaitForSingleObject (pInfo.hProcess, INFINITE);
          }

  CloseHandle(wPipe);

I am using Visual Studio 2008, if it matters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜