hi,
I'd like your advice to this situation.
I have a folder in my lan, in this folder some users put files txt (about one each 15 or 20 minutes)
for aech file I need to read it inside and print some information.
therefore I have to create a .exe that is always active (in background) and start print when it finds a new .txt into the folder.
can you help me?
thanks
exe in background
- damianodec
- Posts: 422
- Joined: Wed Jun 06, 2007 2:58 pm
- Location: Italia
- Contact:
exe in background
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
- karinha
- Posts: 7948
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: exe in background
Code: Select all | Expand
Do While PathFileExists("c:\blabla\qqfoi.txt") = 0
SysWait(.3)
...
EndDo
DLL32 FUNCTION PathFileExists(cPathFileName AS STRING) AS LONG PASCAL ;
FROM "PathFileExistsA" LIB "shlwapi.dll"
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7948
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: exe in background
\samples\testtray.prg
Regards.
Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- damianodec
- Posts: 422
- Joined: Wed Jun 06, 2007 2:58 pm
- Location: Italia
- Contact:
Re: exe in background
thank you karinha, I'll try it
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
- Otto
- Posts: 6410
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 26 times
- Been thanked: 2 times
- Contact:
Re: exe in background
Hello,
I think you should use a timer.
I tested your suggestion with syswait in a loop.
This is consuming 25% of CPU.
Best regards
Otto
I think you should use a timer.
I tested your suggestion with syswait in a loop.
This is consuming 25% of CPU.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- damianodec
- Posts: 422
- Joined: Wed Jun 06, 2007 2:58 pm
- Location: Italia
- Contact:
Re: exe in background
hi Otto,
thank you, any example with timer?
thank you, any example with timer?
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
- Otto
- Posts: 6410
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 26 times
- Been thanked: 2 times
- Contact:
Re: exe in background
Hello,
attached a sample.
This is my anti ransomware program.
This program monitors the data folder.
Only dbf, ftp and cdx files are allowed in the data folder. If a ransomware tries to encrypt a file, the bat-file is called with the shutdown command.
best regards
Otto
Best regards
Otto
attached a sample.
This is my anti ransomware program.

This program monitors the data folder.
Only dbf, ftp and cdx files are allowed in the data folder. If a ransomware tries to encrypt a file, the bat-file is called with the shutdown command.
best regards
Otto
Best regards
Otto
Code: Select all | Expand
#include "FiveWin.ch"
static oWnd, oTimer
//----------------------------------------------------------------------------//
function Main()
DEFINE DIALOG oWnd FROM 3, 3 TO 20, 50 ;
TITLE OemToAnsi( "Testing timers" )
ACTIVATE DIALOG oWnd ;
ON INIT StartTimer()
return nil
//----------------------------------------------------------------------------//
function StartTimer()
DEFINE TIMER oTimer OF oWnd ;
INTERVAL 300 ;
ACTION ( check() )
ACTIVATE TIMER oTimer
return nil
//----------------------------------------------------------------------------//
function check()
local aDir := directory( "x:\xwhdaten\DATAWIN\" + "*.*","DHS")
local I := 1
local cFilename := ""
local lFehler := .f.
local cFehler := ""
oTimer:Deactivate()
FOR I := 1 to len( aDir )
lFehler := .T.
if aDir[ I , 1 ] <> "."
if ALLTRIM ( UPPER( cFileExt( aDir[ I , 1 ] ) ) ) = "DBF"
lFehler := .f.
endif
if UPPER( cFileExt( aDir[ I , 1 ] ) ) = "FPT"
lFehler := .f.
endif
if UPPER( cFileExt( aDir[ I , 1 ] ) ) = "CDX"
lFehler := .f.
endif
if lFehler = .t.
cFehler += aDir [ I, 1 ] + CRLF
FWLOG cFehler
winexec( "abmelden.bat" )
endif
endif
next
oTimer:activate()
return nil
*******************
abmelden.bat
shutdown -S
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- Otto
- Posts: 6410
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 26 times
- Been thanked: 2 times
- Contact:
Re: exe in background
Hello,
>I have a folder in my lan, in this folder some users put files txt (about one each 15 or 20 minutes)
Is the program that writes the TXT files from you. If so then you should create a lock file write the TXT file and then delete the lock file again.
The program with the timer () may only edit the TXT files if there is no lock file.
Best regards
Otto
>I have a folder in my lan, in this folder some users put files txt (about one each 15 or 20 minutes)
Is the program that writes the TXT files from you. If so then you should create a lock file write the TXT file and then delete the lock file again.
The program with the timer () may only edit the TXT files if there is no lock file.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- damianodec
- Posts: 422
- Joined: Wed Jun 06, 2007 2:58 pm
- Location: Italia
- Contact:
Re: exe in background
hi Otto,
txt files in the folder are generated by others application (not mine).
Pratically, there are some users that works with CAD, this CAD make nesting of iron sheet for mecanichal parts end this parts are in txt files in the folder.
I have to intercept this files when it is generated, my exe when there is a new txt have to read inside and print list of parts of txt.
txt files in the folder are generated by others application (not mine).
Pratically, there are some users that works with CAD, this CAD make nesting of iron sheet for mecanichal parts end this parts are in txt files in the folder.
I have to intercept this files when it is generated, my exe when there is a new txt have to read inside and print list of parts of txt.
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)