윈도우 콘솔을 2개 띄우기
영 안된다.
#include <stdio.h>
#include <windows.h>
int main() {
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
// 명시적인 경로와 명령어 설정
char applicationName[] = "C:\\\\Windows\\\\System32\\\\cmd.exe";
char commandLine[] = "/k echo Hello from new console!";
// 새로운 프로세스 생성
if (!CreateProcess(applicationName, commandLine, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) {
printf("CreateProcess failed (%d).\\n", GetLastError());
return -1;
}
// 메인 콘솔에 출력
printf("Hello from main console!\\n");
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return 0;
}