C#의 Process.Start 처럼 ,
C++ 에서도 가능하다.
아래의 예제는 ffmpeg.exe 를 통해 웹에서 재생이 가능한 영상으로 변환 하는 옵션을 포함 하고 있다.
프로세스를 마칠때 까지 해당 쓰레드는 멈춘다.
LPWSTR ConvertToLPWSTR(const std::string& s) { LPWSTR ws = new wchar_t[s.size() + 1]; // +1 for zero at the end copy(s.begin(), s.end(), ws); ws[s.size()] = 0; // zero at the end return ws; } ... cout << "start" << endl; SHELLEXECUTEINFO processInfo; ZeroMemory(&processInfo , sizeof(processInfo)); processInfo.cbSize = sizeof(processInfo); processInfo.lpVerb = ConvertToLPWSTR("open"); processInfo.lpFile = ConvertToLPWSTR("ffmpeg.exe"); processInfo.lpParameters = ConvertToLPWSTR("-y -i capture.wmv -vcodec libx264 -f mp4 -b:v 2048k -r 30 x_wmv_win_mpeg.mp4"); processInfo.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS; processInfo.nShow = SW_HIDE; // SW_SHOW int r = (int)ShellExecuteEx(&processInfo); WaitForSingleObject(processInfo.hProcess, INFINITE); // 프로세스가 끝날때까지 기다림 cout << "end : " << r << endl;
'C++(일반)' 카테고리의 다른 글
sort 사용하기 (0) | 2016.08.19 |
---|---|
Cmd 명령으로 프로그램 실행 하기 (0) | 2016.08.10 |
_memcpy(...) with start Index. (0) | 2016.03.27 |
char 와 unsigned char (0) | 2016.03.27 |
c++ memorystream (0) | 2016.03.25 |
istream(ofstream) 사용시 주의점 ios::binary (0) | 2016.03.25 |