Uziel2101
March 27th, 2008, 02:08 PM
Hey all,
I am writing an MFC app that Sync files for building purposes. There is an option to show a preview of what file(s) would be sycned over to your new directory. I wanted to use CreateProcess to catch that information so that I could display it. However, I haven't been able to actually get CreateProcess() to work for "cmd.exe", I have been able to get it to work for batch file ( thats another story ). here is a snippet of the CreateProcess
STARTUPINFO si;
PROCESS_INFORMATION pi;
SECURITY_ATTRIBUTES saAttr;
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(si);
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0);
SetHandleInformation( hChildStdoutRd, HANDLE_FLAG_INHERIT, 0);
si.hStdError = hChildStdoutWr;
si.hStdOutput = hChildStdoutWr;
si.dwFlags |= STARTF_USESTDHANDLES;
CreateProcess(NULL,(LPWSTR)spawnstr, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
I've tried all kinds of things:
ex:
CreateProcess( (LPWSTR)"cmd.exe", (LPWSTR)spawnstr, ...
spawnstr has something temporary ( I just want to get copying done first )
"xcopy C:\test.txt C:\testingfolder\test.txt"
When debugging my strings look correct, I'm not sure exactly where to go from here...It's most likely something stupid that people will point and laugh at...
Help please? Many thanks in advance.
I am writing an MFC app that Sync files for building purposes. There is an option to show a preview of what file(s) would be sycned over to your new directory. I wanted to use CreateProcess to catch that information so that I could display it. However, I haven't been able to actually get CreateProcess() to work for "cmd.exe", I have been able to get it to work for batch file ( thats another story ). here is a snippet of the CreateProcess
STARTUPINFO si;
PROCESS_INFORMATION pi;
SECURITY_ATTRIBUTES saAttr;
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(si);
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0);
SetHandleInformation( hChildStdoutRd, HANDLE_FLAG_INHERIT, 0);
si.hStdError = hChildStdoutWr;
si.hStdOutput = hChildStdoutWr;
si.dwFlags |= STARTF_USESTDHANDLES;
CreateProcess(NULL,(LPWSTR)spawnstr, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
I've tried all kinds of things:
ex:
CreateProcess( (LPWSTR)"cmd.exe", (LPWSTR)spawnstr, ...
spawnstr has something temporary ( I just want to get copying done first )
"xcopy C:\test.txt C:\testingfolder\test.txt"
When debugging my strings look correct, I'm not sure exactly where to go from here...It's most likely something stupid that people will point and laugh at...
Help please? Many thanks in advance.