Hola a todos....
Necesito correr un servicio en una maquina que reaccione a la existencia o no de un archivo en un folder especifico y que llame a otro ejecutable.
Alguien ha hecho algo asi ?
Algun punto de partida donde mirar, puede ser en c puro.
Apenas alguien ponga un archivo txt en el folder seleccionado, debo llamar instantáneamente a un exe hecho en FWH para procesar ese archivo.
Esa es la idea principal.
Gracias de antemano.
Saludos desde Chile
Adolfo
Servicio en Harbour o FWH
Servicio en Harbour o FWH
Ji,ji,ji... buena la cosa... "all you need is code"
http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Servicio en Harbour o FWH
Puedes usar un TIMER que haga esa comprobación etc.
- AngelSalom
- Posts: 664
- Joined: Fri Oct 07, 2005 7:38 am
- Location: Vinaros (Castellón ) - España
- Contact:
Re: Servicio en Harbour o FWH
Prueba con este código. Parte de él lo utilicé hace muchos años, he probado a compilarlo con versiones más actuales y parece que aún funciona.
Code: Select all
#include "fivewin.ch"
Function Main()
Local oTimer , oDlg, oTray, oIcon
ServiceProcess (1)
DEFINE WINDOW oDlg TITLE "Servicio"
DEFINE ICON oIcon FILE "..\icons\fivewin.ico"
DEFINE TIMER oTimer INTERVAL 6000 OF oDlg ACTION Msginfo ('Busco')
ACTIVATE WINDOW oDlg ;
ON INIT (oTray := (TTrayIcon():New(oDlg,oIcon,"Esperando ...",{||Msginfo ('Click')},{|nRow,nCol|MenuTray(oDlg,nRow,nCol,oTray)})),;
oTimer:ACTIVATE());
VALID oTray:End()
Return (nil)
FUNCTION MenuTray( oDlg,nRow, nCol, oTray )
LOCAL oMenu
MENU oMenu POPUP
MENUITEM "Mostrar" ACTION oDlg:Show(), oDlg:SetFocus()
MENUITEM "Ocultar" ACTION oDlg:Hide()
SEPARATOR
MENUITEM "Cerrar Programa" ACTION Iif(MsgNoYes("Desea Salir","Atención"),Finalizar(),)
ENDMENU
ACTIVATE POPUP oMenu AT nRow, nCol OF oTray:oWnd
RETURN NIL
Function Finalizar()
Quit
Return Nil
//------------------------------
Function ServiceProcess( mode )
//------------------------------
Local nProcessId := 0
Default mode := 0
nProcessId := GCP( )
If Abs( nProcessId ) > 0
RSProcess( nProcessId, mode )
Endif
Return (nil)
//----------------------------------------------------
DLL32 FUNCTION RSProcess(npID AS LONG ,;
nMode AS LONG ) AS LONG ;
FROM "RegisterServiceProcess" LIB "kernel32.DLL"
//----------------------------------------------------
//----------------------------------------------------
DLL32 FUNCTION GCP() AS LONG;
FROM "GetCurrentProcessId" LIB "kernel32.dll"
//----------------------------------------------------
Angel Salom
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
Re: Servicio en Harbour o FWH
Very good Angel, yo haria asi:
Muchas gracias, saludos.
Code: Select all
#include "fivewin.ch"
Function Main()
Local oTimer , oDlg, oTray, oIcon
ServiceProcess (1)
//DEFINE WINDOW oDlg TITLE "Servicio"
DEFINE WINDOW oDlg FROM -10, -10 TO -5, -5 MDI // sin window.
DEFINE ICON oIcon FILE "..\icons\fivewin.ico"
DEFINE TIMER oTimer INTERVAL 12000 OF oDlg ACTION Msginfo ('Busco')
ACTIVATE WINDOW oDlg ;
ON INIT (oTray := (TTrayIcon():New(oDlg,oIcon,"Esperando Servicio",{||Msginfo ('Click')},{|nRow,nCol|MenuTray(oDlg,nRow,nCol,oTray)})),;
oTimer:ACTIVATE());
VALID oTray:End()
Return (nil)
FUNCTION MenuTray( oDlg,nRow, nCol, oTray )
LOCAL oMenu
MENU oMenu POPUP 2007
MENUITEM "Mostrar" ACTION oDlg:Show(), oDlg:SetFocus() ;
FILENAME "..\bitmaps\16x16\info.bmp"
SEPARATOR
MENUITEM "Ocultar" ACTION oDlg:Hide() ;
FILENAME "..\bitmaps\edit.bmp"
SEPARATOR
MENUITEM "Cerrar Programa" ;
ACTION Iif(MsgNoYes("Desea Salir","Atención"),Finalizar(),) ;
FILENAME "..\bitmaps\16x16\exit.bmp"
ENDMENU
ACTIVATE POPUP oMenu AT nRow, nCol OF oTray:oWnd
RETURN NIL
Function Finalizar()
FreeResources()
SysRefresh()
RELEASE All
Hb_GCAll( .T. )
CLEAR MEMORY
PostQuitMessage( 0 )
Quit
Return Nil
//------------------------------
Function ServiceProcess( mode )
//------------------------------
Local nProcessId := 0
Default mode := 0
nProcessId := GCP( )
If Abs( nProcessId ) > 0
RSProcess( nProcessId, mode )
Endif
Return (nil)
//----------------------------------------------------
DLL32 FUNCTION RSProcess(npID AS LONG ,;
nMode AS LONG ) AS LONG ;
FROM "RegisterServiceProcess" LIB "kernel32.DLL"
//----------------------------------------------------
//----------------------------------------------------
DLL32 FUNCTION GCP() AS LONG;
FROM "GetCurrentProcessId" LIB "kernel32.dll"
//----------------------------------------------------
João Santos - São Paulo - Brasil
Re: Servicio en Harbour o FWH
Gracias Angel.. lo probare mañana...
Pero es un servicio al 100%, que se cargue automaticamente al iniciar windows.. o debo llamarlo aunque sea una vez.
Poruqe la idea es ponerlo en una estacion donde el operador no deba realizar nada...
Eso.. mañana le doy un test
Pero es un servicio al 100%, que se cargue automaticamente al iniciar windows.. o debo llamarlo aunque sea una vez.
Poruqe la idea es ponerlo en una estacion donde el operador no deba realizar nada...
Eso.. mañana le doy un test
Ji,ji,ji... buena la cosa... "all you need is code"
http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
- AngelSalom
- Posts: 664
- Joined: Fri Oct 07, 2005 7:38 am
- Location: Vinaros (Castellón ) - España
- Contact:
Re: Servicio en Harbour o FWH
Debes ejecutarlo al iniciar el equipo (pero bueno, eso es lo de menos ya que lo puedes incluir en el inicio) Inicio ► Todos los programas ► Abrir carpeta «Inicio» ► Alojar en ella el acceso directo al programa que queremos que se inicie con Windows.
Angel Salom
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
http://www.visionwin.com
---------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.0
Re: Servicio en Harbour o FWH
En Harbour teneis ejemplo de como tener un servicio en Windows.
Y he de decir que funciona y funciona muy bien.
Y he de decir que funciona y funciona muy bien.
Saludos
Rafa Carmona ( rafa.thefullARROBAgmail.com___quitalineas__)
Rafa Carmona ( rafa.thefullARROBAgmail.com___quitalineas__)
Re: Servicio en Harbour o FWH
Amigos...
He probado el ejemplo y le he hecho las modificaciones que a mi me interesaban...
Hasta el momento todo bien, con un consumo decente de memoria, y de CPU, entre 2 y 2,3 Mb de memoria y hasta un 1% en el proceso de lectura y obtencion de datos desde un archivo.
Veremos con mas calma y mas trabajo como se comporta..
Gracias
Saludos
Desde Chile
Adolfo
He probado el ejemplo y le he hecho las modificaciones que a mi me interesaban...
Hasta el momento todo bien, con un consumo decente de memoria, y de CPU, entre 2 y 2,3 Mb de memoria y hasta un 1% en el proceso de lectura y obtencion de datos desde un archivo.
Veremos con mas calma y mas trabajo como se comporta..
Gracias
Saludos
Desde Chile
Adolfo
Ji,ji,ji... buena la cosa... "all you need is code"
http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050