function CURL_enviaFichero(cCertificado,cCertificadoKey,cFicheroAenviar,cFichRespAeat,cHttpAeat)
local cCurl :="C:\hb32\comp\mingw\bin\curl.exe"
local cOpciones:='--connect-timeout 60 -m 60 -S -L --cert ' + cCertificado + ' --key ' + cCertificadoKey +;
' -d @' + cFicheroAenviar + ' -o "' + cFichRespAeat +'" ' +cHttpAeat+ " > "+ "Salida.Txt"
local nErrorShellExecute:=32 // A partir del valor 32 inclusive es correcto y es el handler asignado al ejecutable
if FILE(cCurl)
nError = ShellExecute(oWnd,"Open",cCurl,cOpciones,,3)
if nError < 32 //error
msgstop(erroresShellExecute(nError),"ERROR AL EJECUTAR COMANDO DEL S.O.")
else
msginfo("COMANDO PROCESADO","INFORMACION")
endif
else
msgstop("NO EXISTE EL PROGRAMA: "+cCurl,"ERROR DEL SISTEMA")
endif
/* Windows 10 NO lo encuentra a pesar de estar allí instalado. 25/03/2019.
De modo que el siguiente código siempre devuelve el error nº 2 de ShellExecute
if FILE("C:\Windows\System32\curl.exe")
nError = ShellExecute(oWnd,"Open","C:\Windows\System32\curl.exe",cOpciones,,3)
if nError < 32 //error
msgstop(erroresShellExecute(nError),"ERROR AL EJECUTAR COMANDO DEL S.O.")
else
msginfo("COMANDO PROCESADO","INFORMACION")
endif
else
msgstop("NO EXISTE EL PROGRAMA: "+"C:\Windows\System32\curl.exe","ERROR DEL SISTEMA")
endif
*/
return
/* Instrucciones de ShellExecute:
https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shellexecutea#return-value
Devuelve:
El valor devuelto es el identificador de instancia de la aplicación que se abrió o se imprime, si la función se realiza correctamente.
(Este controlador también podría ser el identificador de una aplicación de servidor DDE.)
Una devolución de valor menor o igual a 32 especifica un error.
Errores:
La función ShellExecute() devuelve el valor 31 Si no hay ninguna asociación para el tipo de archivo especificado,
o si no hay ninguna asociación para la acción especificada en el tipo de archivo.
Los demás valores de error posibles son:*/
function erroresShellExecute(nError)
local nPos:=0
local aErrores:={ {0, "System was out of memory, executable file was corrupt, or relocations were invalid."},;
{2, "File was not found."},;
{3, "Path was not found."},;
{5, "Attempt was made to dynamically link to a task, or there was a sharing or network-protection error."},;
{6, "Library required separate data segments for each task."},;
{8, "There was insufficient memory to start the application."},;
{10,"Windows version was incorrect."},;
{11,"Executable file was invalid. Either it was not a Windows application, or there was an error in the .exe image."},;
{12,"Application was designed for a different operating system."},;
{13,"Application was designed for MS-DOS 4.0."},;
{14,"Type of executable file was unknown."},;
{15,"Attempt was made to load a real-mode application (developed for an earlier version of Windows)."},;
{16,"Attempt was made to load a second instance of an executable file containing multiple data segments that were not marked read-only."},;
{19,"Attempt was made to load a compressed executable file. The file must be decompressed before it can be loaded."},;
{20,"Dynamic-link library (DLL) file was invalid. One of the DLLs required to run this application was corrupt."},;
{21,"Application requires Microsoft Windows 32-bit extensions."},;
{31,"La extensión del archivo no tiene asociación"} }
nPos=ascan(aErrores,{|aVal| aVal[1]==nError})
return iif(nPos<>0,str(nError,3)+" - "+aErrores[nPos,2],"SIN ERRORES")