Help with making a background process in Windows

DimSum

New Member
Hi all,

I want to make a program/dll that'll run as a background process in Windows. I want to a process that can be called when another program tells it to. So lets say that I have a program called Foo. And when I start up Foo it'll tell the process to come alive, and it'll send some data to it. And, then the process will go back to "sleep" or inactive. And then, when you close Foo, it'll tell the process to wake up again and it'll send it some more information.

I'm not even 100% sure that this can be done in Windows. Is there something like this?? And if so does it have a name??? And can anyone gimme some basic help on how to start something like this???

thanks all.

-Phil
 

xasp

New Member
use a socket server

Hello,

I'm not saying that this is THE answer, but this is how I solved that problem:

Make your background program as being a 'server' process -> use a socket server, and make it listen/accept connections on a specific port on Localhost.

The other programs (Progress/Non-Progress) can then use sockets to connect to that same port on Localhost and can send/receive messages over this connection.

This might for example allow you to write a macro in Excell which addresses a underlying Progress program and shares information with it (of course, I'm talking about exchanging bits of info., not passing entire tables through).
This has the advantage that you don't have to fiddle with ODBC connections, nor Progress Open-client ActiveX's, you just need a Progress 4GL client on the client machine.

How to build a server application in Progress: check out the electronic documentation, chapter 10 of "Progress External Program Interfaces".

Hope this helped.
 
Their are windows API routines to perform inter-process communication - their called named pipes. Your service process (Progress or Non-progress) can also talk with other processes (Progress or Non-progress) via the windows Named Pipe procedures.

This gives you the advantage that a lot of the message passing routines are already coded and working. Named pipes work between machines like TCP socket code, but the disadvantage is that you can only really comunicate between windows boxes (you couldn't have a server process running on a UNIX system).

If you are using Named Pipes from progress you will need the following API procedure definitions:

procedure CreateNamedPipeA external "kernel32.dll":
def input parameter ipc_pipe as char.
def input parameter ipl_OMode as long.
def input parameter ipl_PMode as long.
def input parameter ipl_MaxInst as long.
def input parameter ipl_OBuffSize as long.
def input parameter ipl_IBuffSize as long.
def input parameter ipl_Sec as long.
def input parameter ipl_TimeOut as long.
def return parameter opl_Phandle as long.
end procedure.

procedure CreateFileA external "kernel32.dll":
def input parameter ipc_pipe as char.
def input parameter ipl_DAccess as long.
def input parameter ipl_DShare as long.
def input parameter ipl_Sec as long.
def input parameter ipl_HowCreate as long.
def input parameter ipl_FAttrib as long.
def input parameter ipl_FHandle as long.
def return parameter rpl_FHandle as long.
end procedure.


procedure PeekNamedPipe external "kernel32.dll":
def input parameter ipl_hpipe as long.
def input-output parameter iopc_Text as memptr.
def input parameter ipl_DataSize as long.
def input-output parameter iopl_Read as memptr.
def input-output parameter iopl_Avail as memptr.
def input-output parameter iopl_UnRead as memptr.
def return parameter rpl_error as long.
end procedure.

procedure ReadFile external "kernel32.dll":
def input parameter ipl_hpipe as long.
def input-output parameter iopc_Text as memptr.
def input parameter ipl_ReadSize as long.
def input-output parameter iopl_Read as memptr.
def input parameter ipl_DStruct as long.
def return parameter rpl_error as long.
end procedure.

procedure WriteFile external "kernel32.dll":
def input parameter ipl_hpipe as long.
def input parameter ipc_Text as char.
def input parameter ipl_WriteSize as long.
def input parameter ipm_Written as memptr.
def input parameter ipl_DStruct as long.
def return parameter rpl_error as long.
end procedure.

procedure DisconnectNamedPipe external "kernel32.dll":
def input parameter ipl_hpipe as long.
def return parameter rpl_error as long.
end procedure.
 

DimSum

New Member
thanks guys,

but I looking at a Service Application for Windows. I think that's what i'm looking for.

does anyone know if this is a good option??

thanks.

-Phil
 
Top