Tengo un programa que se actualiza, seg煤n si la version que tiene el cliente esta o no actualizada, haciendo click en un formulario de actualizacion, que el cliente elije ejecutar.
Para ello, descargo el programa actualizado desde un ftp.
Para ello, utilice una funcion que escribio Biel en su blog (http://bielsys.blogspot.com/2009/04/act ... ca-de.html) hace ya mucho tiempo.
El problema me surge ahora, en algunas maquinas con Windows 10 (no en todas), descarga el programa, pero no renombra el exe descargado por el actual.
Alguien le ha pasado o tiene alguna solucion alrtenativa
Este es mi codigo:
聽 聽cFile := "aplicacion.exe"
cDirLocal := hb_curdrive()+":\"+CurDir()
聽 聽IF ConectaServerFtp() 聽 聽 聽
聽 聽 聽 聽aFiles:=oFtp:ListFiles('public_html/descargas/aplicacion.exe')
聽 聽 聽 聽IF LEN(aFiles) = 0
聽 聽 聽 聽 聽 MsgStop("Error de descarga al comparar!!","ERROR")
聽 聽 聽 聽 聽 oFtp:Close()
聽 聽 聽 聽 聽 RETURN .F.
聽 聽 聽 聽ENDIF
聽 聽 聽 聽nSize := aFiles[1,2] 聽 聽 聽
聽 聽 聽 聽IF nSize = 0
聽 聽 聽 聽 聽 MsgStop("Error de descarga al bajar!!","ERROR")
聽 聽 聽 聽 聽 oFtp:Close()
聽 聽 聽 聽 聽 RETURN .F.
聽 聽 聽 聽ENDIF 聽
聽 聽 聽 聽oFtp:DownLoadFile( ".\tmp.exe", 'public_html/descargas/aplicacion.exe' )
聽 聽 聽 聽ELSE
聽 聽 聽 聽oFtp:Close()
聽 聽 聽 聽MsgStop("Fallo la conexion...","Error")
聽 聽 聽 聽RETURN nil
聽 聽ENDIF 聽 聽
聽 聽oFtp:Close()
聽 聽IF FSIZE(".\tmp.exe") = nSize .AND. nSize > 0
聽 聽 聽 MsgWait("Reinciciando la aplicacion","Espere",1) 聽 聽 聽
聽 聽 聽 ResToFile()
聽 聽 聽 WinExec( cDirlocal+'\ActVer.exe '+ cFile ,0)
聽 聽 聽 PostQuitMessage(0)
聽 聽 聽 QUIT
聽 聽 聽 ELSE
聽 聽 聽 MsgStop("Error de descarga al renombrar!!","ERROR")
聽 聽 聽 QUIT
聽 聽ENDIF 聽
RETURN .t.
//----------------------------------------------------------------------------------------
#pragma BEGINDUMP
#include "Windows.h"
#include "hbApi.h"
HB_FUNC( RESTOFILE )
{
HRSRC res=FindResource(NULL,"ACTVER",RT_RCDATA);
LPDWORD bytesWritten;
int size=SizeofResource(NULL,res);
HGLOBAL hRes=LoadResource(NULL,res);
unsigned char *pRes=(unsigned char *)LockResource(hRes);
HANDLE hFile=CreateFile("ACTVER.EXE",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
WriteFile(hFile,pRes,size,&bytesWritten,NULL);
CloseHandle(hFile);
}
#pragma ENDDUMPEl codigo en C de ACTVER.EXE es el siguiente:
#include "stdio.h"
#include "windows.h"
int main( int argc, char *argv[])
{
Sleep(700);
DeleteFile( argv[1]);
rename( "tmp.exe",argv[1]);
WinExec(argv[1],argc);
return EXIT_SUCCESS;
}Gracias de antemano