Ok, now I'm using this function:
void run( LPCTSTR cmd, LPCTSTR dir)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
si.dwFlags = STARTF_USESHOWWINDOW ;
si.wShowWindow = SW_SHOW;
TCHAR buffer[ MAX_PATH + 1];
memset( buffer, 0, sizeof( buffer));
_tcscpy( buffer, cmd);
// create the process
BOOL res = CreateProcess( NULL
, buffer
, NULL
, NULL
, FALSE
, CREATE_NEW_PROCESS_GROUP
, NULL
, dir
, &si, &pi);
if ( !res)
{
// handle error
}
WaitForSingleObject( pi.hProcess, INFINITE );
}
but I've got a problem. I cal it like this: run(".\whatever.exe -blabla", ".\").
It works fine, but I don't want to show command prompt window. So how can I hide this window?