萌新求教 c++使用createprocess调命令行出错
#include "stdafx.h"#include <windows.h>
int main(int argc, char* argv[])
{
CreateProcess(
_T("C:\\Windows\\SysWOW64\\cmd.exe"),
_T("/c calc"),
);
}
想知道是哪里出了错
#include <cstdio> #include <windows.h> int main( void ) { wchar_t cmdline[MAX_PATH]; GetSystemDirectoryW( cmdline, _countof(cmdline) ); wcscat( cmdline, L"/calc.exe" ); STARTUPINFOW si = { sizeof(si) }; PROCESS_INFORMATION pi; BOOL b = CreateProcessW( NULL, cmdline , NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL , &si, &pi ); if( !b ) { puts( "failed to invoke CreateProcessW" ); return 1; } WaitForSingleObject( pi.hProcess, INFINITE ); }