how to detect app if running in memory ?

how to detect app if running in memory ?

Postby ShumingWang » Wed Dec 17, 2008 10:17 am

Hi,
In main prg ,I do a call upgrade to download from web and overwrite main.exe , but the mian exe not close in memory,so upgrade will failure.

main.prg
...
define window ownd
...
... button action (ownd:end(),winexec("upgrade.exe"))
activate window ownd
other close
return

but when running upgrade.exe, the the mian exe still in memory ,so upgrade will failure.
If can tetect main.exe is running , waiting till it close, the download begins.
Fwh 8.01, Harbour 1.0.0 , BCC551
Thanks !
Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby anserkk » Wed Dec 17, 2008 10:32 am

Is this what u r looking for

Code: Select all  Expand view
// Check whether the application is already running in the same PC
if IsExeRunning( cFileName( HB_ARGV( 0 ) ) )
   MsgWait( "This application is already running", "Application Name" )
   Quit
endif

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby hag » Wed Dec 17, 2008 11:51 pm

ShumingWang

Do you have some code that will automatically search an FTP site for upgrades. If you do can you post a copy. Thanks
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby ShumingWang » Thu Dec 18, 2008 12:48 am

Hag,
For the www /web mode download more faster, so I change from FTP to WEB mode.
I place a .ini file contian version id:
local nsize,afiles:={},oInternet,i,newversionid,odb1,lok:=.f.
local cwebpath:="http://www.xtech.com.cn/down/xerp6.1"+if(oserver:cCharset=="big5","f","")

local cpath:=curdrive()+":\"+curdir()+"\tmp"

hLib = LOADLIBRARY( "urlmon.dll")
while .t.

if URLDownloadToFile( 0, cwebpath+"/version.ini", cpath+"\version.ini", 0, 0 ) == 0

oIni:=Tini():New(cpath+"\version.ini")
newversionid:=oIni:GET("version","version_id"," ")

if ALLTRIM(newversionid)<=ALLTRIM(version_id)
msgstop2("Already new version"+version_id,"Stop")
else
if msgyesno2("Download new version"+newversionid,"Please confirm")
lok:=.t.
endif
endif
else
MsgStop( "Can't download!", "Warnning" )
end
exit
enddo

FREELIBRARY( hLib )

if !lok; return ; end
download codes
return


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

Regards!
Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby hag » Thu Dec 18, 2008 12:59 am

Thanks for the quick response.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Postby ShumingWang » Thu Dec 18, 2008 1:15 am

Anserkk,
The IsExeRunning( "main.exe") return .f., ether windows task table shows no.
But it seems the file still not release even wait many minutes, URLDownloadToFile( 0, cwebpath+"/"+afiles[i], cpath+"\"+afiles[i], 0, 0 ) == 0 // failure

Best regards!
Shuming Wang
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby anserkk » Thu Dec 18, 2008 6:16 am

Dear ShumingWang,

A Hint :

I think you should try to get the window Handle of the Running.Exe, If u search this forum, you will find how to do it.

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 104 guests