I Implemented it this way for FWPPC (FiveWin for Pocket PC) long time ago:
I have not tested it but it may work. Use it as WaitRunEx() with the same params as WaitRun()
- Code: Select all Expand view
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
LPWSTR AnsiToWide( LPSTR cAnsi );
LPSTR WideToAnsi( LPWSTR cWide );
static HINSTANCE ShellExecute( HWND hWnd, LPSTR lpOperation, LPSTR lpFile, LPSTR lpParameters,
LPSTR lpDirectory, INT nShowCmd, BOOL bWait )
{
SHELLEXECUTEINFO sei;
LPWSTR pWVerb = AnsiToWide( lpOperation );
LPWSTR pWFile = AnsiToWide( lpFile );
LPWSTR pWParams = AnsiToWide( lpParameters );
LPWSTR pWDir = AnsiToWide( lpDirectory );
HINSTANCE hRes;
memset( &sei, 0, sizeof( sei ) );
sei.cbSize = sizeof( sei );
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.hwnd = hWnd;
sei.lpVerb = pWVerb;
sei.lpFile = pWFile;
sei.lpParameters = pWParams;
sei.lpDirectory = pWDir;
sei.nShow = nShowCmd;
hRes = ( HINSTANCE ) ShellExecuteEx( &sei );
hb_xfree( pWVerb );
hb_xfree( pWFile );
hb_xfree( pWParams );
hb_xfree( pWDir );
if( bWait )
WaitForSingleObject( sei.hProcess, INFINITE );
return hRes;
}
HB_FUNC( WAITRUNEX )
{
LPSTR lpCmdLine = ( char * ) hb_parc( 1 );
UINT uCmdShow = hb_parnl( 2 );
hb_retnl( ( LONG ) ShellExecute( ( HWND ) 0, "open", lpCmdLine, "", "", uCmdShow, TRUE ) );
}
#pragma ENDDUMP