EgtExecutor 1.9f1 :

- aggiunta funzuine Lua EgtWinExec per lanciare l'esecuzione di un nuovo processo.
This commit is contained in:
Dario Sassi
2018-06-01 10:57:49 +00:00
parent 98dc896a01
commit 4bbfabfeb2
2 changed files with 28 additions and 6 deletions
BIN
View File
Binary file not shown.
+28 -6
View File
@@ -272,26 +272,26 @@ LuaOutLog( lua_State* L)
static int
LuaOutBox( lua_State* L)
{
// 3 o 4 parametri : stringa, titolo, icona [, bModal]
// 2 o 3 parametri : stringa, titolo [, icona]
string sOut ;
LuaCheckParam( L, 1, sOut)
string sTitle ;
LuaCheckParam( L, 2, sTitle)
string sIcon ;
LuaCheckParam( L, 3, sIcon)
int nIcon = MB_ICONINFORMATION ;
LuaGetParam( L, 3, sIcon) ;
int nIcon = 0 ;
ToUpper( sIcon) ;
if ( sIcon == "ERROR")
nIcon = MB_ICONERROR ;
else if ( sIcon == "WARNING")
nIcon = MB_ICONWARNING ;
bool bModal = true ;
LuaGetParam( L, 4, bModal) ;
else if ( sIcon == "INFO")
nIcon = MB_ICONINFORMATION ;
LuaClearStack( L) ;
// emetto la finestra di dialogo
HWND hTopWnd = ExeGetMainWindowHandle() ; // FindTopWindow() ;
int nRes = MessageBox( hTopWnd, stringtoW( sOut), stringtoW( sTitle),
MB_OKCANCEL | nIcon | ( bModal ? MB_TASKMODAL : MB_SYSTEMMODAL)) ;
MB_OKCANCEL | nIcon | MB_TASKMODAL) ;
// risultato (Ok->true, Cancel->false)
LuaSetParam( L, ( nRes == IDOK)) ;
return 1 ;
@@ -614,6 +614,26 @@ LuaGetLanguage( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaWinExec( lua_State* L)
{
// un solo parametro : CmdLine
string sCmdLine ;
LuaCheckParam( L, 1, sCmdLine)
LuaClearStack( L) ;
// mando in esecuzione la linea di comando
STARTUPINFO si ;
PROCESS_INFORMATION pi ;
ZeroMemory( &si, sizeof(si)) ;
si.cb = sizeof(si) ;
ZeroMemory( &pi, sizeof(pi)) ;
bool bOk = ( CreateProcess( NULL, stringtoW( sCmdLine), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) != FALSE) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
const int MAX_CTRLS = 6 ;
static int s_nCtrls = 0 ;
@@ -776,5 +796,7 @@ LuaInstallGeneral( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtIs64bit", LuaIs64bit) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetLanguage", LuaGetLanguage) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtWinExec", LuaWinExec) ;
return bOk ;
}