-
A form of IPC
I have a server program that runs as an NT service. I need a way for it to open an application and give it some data (possibly with command line arguments), and a way for the program to communicate information back to the server and vis-versa.
Could anyone tell me what I should look up to allow communication like this? Keep in mind the server will start multiple instances of this program, and I'd rather the program was a main() program rather than a winmain().
-
Your server can use CreateProcess() to create the subordinate processes, if necessary, with command line arguments. This...
>>> I'd rather the program was a main() program rather than a winmain().
... is your biggest problem. If you don't have imediate access to the Windows loop in the subordinate tasks, (you can get at it, but it's fiddly), so a lot of the sophisticated inter-process communication techniques become difficult/impossible to use. You may well be able to fiddle your apps to use a pipe ir mailslot, but without more information, it's difficult to comment.
-
Ok, my server cannot create pipes on its own, so I must call a program that creates the pipes and handles all the output.
The server is a web server, and the application it calls has to handle requests for CGI files.
All it has to hand the CGI handler is info about the file, CGI environment variables, and the socket descriptor. This could all be done from arguments when the programs called.
All the CGI handler must do is return true/false, depending on if it succeeded or failed. It also sends information out using the socket descriptor it was given. The server just needs to call it and catch a return value, thats about all. In fact I dont think theres much need for any real IPC.
What functions could I use to create a program and get its return value?
-
Use CreateProcess() to create you subprocess, (can use command line arguments), and GetExitCodeProcess() to find out what it exited with.