Page 1 of 1
Shellexecuteex is ported to FW / Harbour ?
Posted: Sat May 14, 2016 7:52 pm
by hidroxid
Hello
I need execute the web explorer and wait until this close.
With WaitRun() using "Rundll32" dont work
ShellExecute() open but return the control to program.
I read that ShellexExecuteEx has more control but i think this is not ported to FW / Harbour.
Any one has it?
Regards
Re: Shellexecuteex is ported to FW / Harbour ?
Posted: Sat May 14, 2016 8:21 pm
by Antonio Linares
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
#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