Let the application listen to commands from outside

Hi,

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!!!
svennemanAsked:
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.

MaximilianopCommented:
 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.
0
BLaymanCommented:
PsuedoCode

func PrevInst(NameOfWindow:String): boolean
var
  WHandle,
  ApplicationHandle : HWnd;
begin
  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);
      end;
      if (IsWindowVisible(WHandle))
      then SetForegroundWindow(WHandle);
    end;
  end;
end;

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

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?


0
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
Delphi

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.