csdn_viking 的方法正确// Allocate a new console AllocConsole();// Startup your console program STARTUPINFOA si = { 0 };PROCESS_INFORMATION pi = { 0 };if (!CreateProcess(NULL, _T("command.com"), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) { _cprintf("CreateProcess failed with code %d.\n", GetLastError()); }// Close the new console FreeConsole();
_cprintf("Hello\n");//Std console output Sleep(2000);
FreeConsole();//destroy console
方法还是有的,不知道是不是 对你要求太高,,
AllocConsole();// Startup your console program
STARTUPINFOA si = { 0 };PROCESS_INFORMATION pi = { 0 };if (!CreateProcess(NULL, _T("command.com"), NULL, NULL,
TRUE, 0, NULL, NULL, &si, &pi))
{
_cprintf("CreateProcess failed with code %d.\n", GetLastError());
}// Close the new console
FreeConsole();
或
WinExec("command /k aaa.exe",SW_NORMAL); //执行完后不关闭DOS窗口