如何使用CreateProcess
我原来用系统命令删除文件夹下的文件:
char CurPath1[MAX_PATH];
GetCurrentDirectory(MAX_PATH,CurPath1); //find the absolute path.
CurPath = _T(CurPath1);
CString Str = "del " + ("\"" + CurPath + "\"") + "\\output\\*.txt" ;
system(Str) ;
以上代码是正确的,但是又DOS窗口跳出。于是我想用CreateProcess:
STARTUPINFO si;
PROCESS_INFORMATION hi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&hi, sizeof(hi));
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
CString Str = "del " + ("\"" + CurPath + "\"") + "\\output\\*.txt" ;
LPTSTR pSter = Str.GetBuffer();
CreateProcess(NULL, pSter, NULL, NULL, FALSE, 0, NULL, NULL, &si, &hi); //delete the previous output files.
Str.ReleaseBuffer();
dos窗口的确没有跳出了,但是这段代码压根就没有删除指定文件夹下的文件。
请问问题出在哪里?
3X