Hi,
my.exe :
function main()
define dialog odlg source "odlg"
define button of odlg action (winexec(downloadfiles.exe),odlg:end())
activate dialog odlg
Return
Problem is that before close my.exe, the downloadfiles.exe is already running and donwload my.exe from web site,so my.exe will be overwrite fail.
Thanks !
Shuming Wang
call another excute file and close itself ?
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Shuming,
Code: Select all
#include "FiveWin.ch"
function Main()
local lUpgrade := .F.
DEFINE DIALOG oDlg RESOURCE "odlg"
@ 2, 2 BUTTON "Upgrade" OF oDlg SIZE 80, 20 ;
ACTION ( lUpgrade := .T., oDlg:End() )
ACTIVATE DIALOG oDlg
if lUpgrade
WinExec( "downloadfiles.exe" )
endif
return nil
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
Antonio,
The main my.exe file is still exist in memory and running during winexe("copyfile.exe").
#include "FiveWin.ch"
function Main()
local lUpgrade := .F.
DEFINE DIALOG oDlg RESOURCE "odlg"
@ 2, 2 BUTTON "Upgrade" OF oDlg SIZE 80, 20 ;
ACTION ( lUpgrade := .T., oDlg:End() )
ACTIVATE DIALOG oDlg
if lUpgrade
hLib = LOADLIBRARY( "urlmon.dll")
URLDownloadToFile( 0, "www.my.com/down/my.exe", ".\tmp\my.exe", 0, 0 ) == 0
FREELIBRARY( hLib )
WinExec( "copyfile.exe" )
endif
return nil
DLL32 FUNCTION URLDownloadToFile(pCaller AS LONG,szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG);
AS LONG PASCAL;
FROM "URLDownloadToFileA";
LIB hlib
copyfile.prg
#include "fivewin.ch"
FUNCTION main(cpath)
local afiles
msgwait("正在更新文件","",2)
afiles:=directory(".\tmp\*.*")
for i:=1 to len(afiles)
copyfile( "\"+CURDIR()+"\tmp\"+afiles[i,1] ,afiles[i,1] ,.f.)
next
winexec("my.exe")
return
Thank you!
Shuming Wang
The main my.exe file is still exist in memory and running during winexe("copyfile.exe").
#include "FiveWin.ch"
function Main()
local lUpgrade := .F.
DEFINE DIALOG oDlg RESOURCE "odlg"
@ 2, 2 BUTTON "Upgrade" OF oDlg SIZE 80, 20 ;
ACTION ( lUpgrade := .T., oDlg:End() )
ACTIVATE DIALOG oDlg
if lUpgrade
hLib = LOADLIBRARY( "urlmon.dll")
URLDownloadToFile( 0, "www.my.com/down/my.exe", ".\tmp\my.exe", 0, 0 ) == 0
FREELIBRARY( hLib )
WinExec( "copyfile.exe" )
endif
return nil
DLL32 FUNCTION URLDownloadToFile(pCaller AS LONG,szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG);
AS LONG PASCAL;
FROM "URLDownloadToFileA";
LIB hlib
copyfile.prg
#include "fivewin.ch"
FUNCTION main(cpath)
local afiles
msgwait("正在更新文件","",2)
afiles:=directory(".\tmp\*.*")
for i:=1 to len(afiles)
copyfile( "\"+CURDIR()+"\tmp\"+afiles[i,1] ,afiles[i,1] ,.f.)
next
winexec("my.exe")
return
Thank you!
Shuming Wang
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Shuming,
In downloadfiles.exe do this:
So it will wait until my.exe finishes
In downloadfiles.exe do this:
Code: Select all
while GetModuleHandle( "my.exe" ) != 0
SysRefresh()
end
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
I have done this in the past:
Hope this helps,
Jeff
Code: Select all
SHELLEXECUTE(0,0,"DownloadFile.exe",0,0,1 )
dbcloseall()
freelibrary( hBorland )
set resources to
clear memory
ResAllFree()
if ! empty( oWnd )
oWnd:end()
endif
quit
Jeff
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China