728x90
CMD로 특정 명령어를 실행하고 완료시까지 대기를 하려면
SHELLEXECUTEINFO 구조체를 사용해서 ShellExecuteEx SellAPI를 이용하면 됩니다
void CMyClass::Commander(CString strCommand)
{
SHELLEXECUTEINFO ExecInfo;
memset(&ExecInfo, NULL, sizeof(SHELLEXECUTEINFO));
ExecInfo.cbSize = sizeof(ExecInfo);
ExecInfo.lpVerb = _T("open");
ExecInfo.lpFile = _T("cmd.exe");
ExecInfo.lpParameters = strCommand;
ExecInfo.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
ExecInfo.nShow = SW_HIDE;
ShellExecuteEx(&ExecInfo);
WaitForSingleObject(ExecInfo.hProcess, INFINITE);
}
위와 같이 간단한 함수로 구현이 가능합니다
제 글이 도움이 되셨다면 댓글 & 공감 부탁드려요 😀
728x90
반응형
'Application > MFC' 카테고리의 다른 글
[MFC] WriteFile & ReadFile & OVERLAPPED 사용 방법 (0) | 2023.03.17 |
---|---|
[MFC] Static 글자 색 및 배경 색 변경 (0) | 2023.03.14 |
[MFC] 난수 생성하기(랜덤 값 생성) (0) | 2023.03.08 |
[MFC] 응답 없음 회피하기 (0) | 2023.02.22 |
[MFC] 심볼릭 링크 혹은 정션 링크 위치 가져오기 (0) | 2023.02.21 |