Sending double quote character to CreateProcess?

Posted by karikari on Stack Overflow See other posts from Stack Overflow or by karikari
Published on 2011-01-02T12:52:31Z Indexed on 2011/01/03 1:53 UTC
Read the original article Hit count: 514

Filed under:

I want to send the double quote character to my CreateProcess function. How can I do the correct way? I want to send all of this characters: "%h"

CreateProcess(L"C:\\identify -format ",L"\"%h\" trustedsnapshot.png",0,0,TRUE,NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo);

Here is the full code:

int ExecuteExternalFile()     
{ 
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;

CreateProcess(L"C:\\identify",L" -format \"%h\" trustedsnapshot.png",0,0,TRUE,NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo);



CloseHandle(wPipe);

char buf[100];
DWORD reDword; 
CString m_csOutput,csTemp;
BOOL res;
do
{
  res=::ReadFile(rPipe,buf,100,&reDword,0);
  csTemp=buf;
  m_csOutput+=csTemp.Left(reDword);
}while(res);

//return m_csOutput;
float fvar; 
//fvar = atof((const char *)(LPCTSTR)(m_csOutput));  ori


//fvar=atof((LPCTSTR)m_csOutput);
fvar = _tstof(m_csOutput);

const size_t len = 256;
wchar_t buffer[len] = {};
_snwprintf(buffer, len - 1, L"%d", fvar);


MessageBox(NULL, buffer, L"test print createprocess value", MB_OK);

return fvar;
}

I need this function to return the integer value from the CreateProcess.

© Stack Overflow or respective owner

Related posts about visual-c++