Let the application listen to commands from outside

Posted on 2003-03-23
Medium Priority
Last Modified: 2010-08-05

Does anyone have a solution on how to get an delphi application written with CLX for cross system compability to listen for commands from the outside.

The program will not have any visible interface but will run in the background.
The program will be a server which will listen for incoming requests.

this is how I want it setup:

call server.exe to start the program
call lets say server.exe -stop to stop the server (kill the process)
call server.exe -reboot to restart the program

I have no idea on how to do that, anyone can give me a hint or two.
I just became a member here so I couldnt give more than 50 points for this question.

Thanks alot!!!
Question by:svenneman
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8192410
 First of all, when ever you call the server.exe file, you will creat eanother instance of the app, so what you could do is to manipulate the previous instance of the app I don't exactly recall the code, but I think the functions are with Application.PreviousInstance...

So what you should do is the next:
  Have a string variable (let's call it commands)
  When the app is run, check if there are previous instances
  If there's a previous instance, and there's a command, set's previous instance's commands variable, to the command.
  close the newer instance.

Accepted Solution

BLayman earned 150 total points
ID: 8193636

func PrevInst(NameOfWindow:String): boolean
  ApplicationHandle : HWnd;
  Result := TRUE;
  if (AlreadyRunning(pchar(WindowName)))
    WHandle := FindWindow(NIL, pchar(WindowName));
    if (WHandle <> 0)
      if (not IsWindowVisible(WHandle))
        ApplicationHandle := GetWindow(WHandle, GW_OWNER);
        if (ApplicationHandle <> 0)
        then ShowWindow(ApplicationHandle, SW_RESTORE)
        else ShowWindow(WHandle, SW_RESTORE);
      if (IsWindowVisible(WHandle))
      then SetForegroundWindow(WHandle);

Not an exact match but that should get you going...

Author Comment

ID: 8195868
I dont want to have a windowed application.

it should not have any interface at all in fact.

I would like it to run as a daemon at linux and as an invisible process or service in windows.

now I see that you use windowname and stuff like that, but if I dont have any form how would it be done then?

or is window available even without a form?


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question