| Followings are the useful example can run shell command. /*
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:
.
.
.
above source
.
.
.
KShellExecute( NULL, "http://strcpy.com",NULL, NULL);
* Note: The above code must be included in the same source. |