0

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 parameterB = _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.

4

0 回答 0