FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour how to detect app if running in memory ?
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
how to detect app if running in memory ?
Posted: 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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
how to detect app if running in memory ?
Posted: Wed Dec 17, 2008 10:32 AM
Is this what u r looking for

// 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
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
how to detect app if running in memory ?
Posted: 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
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
how to detect app if running in memory ?
Posted: 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

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
how to detect app if running in memory ?
Posted: Thu Dec 18, 2008 12:59 AM

Thanks for the quick response.

Thank you

Harvey
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
how to detect app if running in memory ?
Posted: Thu Dec 18, 2008 01: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
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
how to detect app if running in memory ?
Posted: Thu Dec 18, 2008 06: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

Continue the discussion