How to run shell command by MFC ? | |||
| |||
/* Programmed 1998 by Kurapa Chunun Kang (kurapa@kurapa.com) By below function, you can run shell command easily. */ #include <shellapi.h> void KShellExecute(HWND handle, LPCTSTR exe, LPCTSTR param, LPCTSTR dir) { DWORD ExitCode; SHELLEXECUTEINFO SEInfo; memset( &SEInfo, 0, sizeof(SEInfo)); SEInfo.cbSize = sizeof(SHELLEXECUTEINFO); SEInfo.fMask = SEE_MASK_NOCLOSEPROCESS; SEInfo.hwnd = handle; SEInfo.lpFile = exe; SEInfo.lpParameters = param; SEInfo.lpDirectory = dir; SEInfo.nShow = SW_HIDE; // SW_SHOWNORMAL; if (ShellExecuteEx(&SEInfo)==TRUE) { do { GetExitCodeProcess(SEInfo.hProcess, &ExitCode); Sleep(500); } while (ExitCode); // wait until the command is finished } } If you want to launch browser for specific URL, simple run as below: . * Note: The above code must be included in the same source.. . above source . . . KShellExecute( NULL, "http://strcpy.com",NULL, NULL); Tags: BrowseDialog C++ ShellExecute ShellExecuteEx | |||
| |||
| |||
Login for comment |