Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

577 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