Let the application listen to commands from outside


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!!!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 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.

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...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
svennemanAuthor Commented:
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?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.