Apologies for the duplication.

As I understand it, mailslots may be an answer.
However I cannot seem to write to one.
Create/open okay, but always get "access denied" when writing.
If anyone cares, I will post the code.

What I like about mailslots, is that, according to the Windows
documentation, the system shuts down the mailslot when the last process
using it exits. So (theoretically), if your program crashes, it does not
leave an open file or pipe. Untested thought. Might be wrong.

The server/listening/TCP solution seems reasonable.
Do I understand correctly?

(1) There would have to be a server process running on the server machine:
call it "appman". So every time an application starts, it would have to
ensure "appman" is running on the server. If not, fire it up.

(2) The internet classes supplied with Delphi 5 could be used
(TServerSocket, TClientSocket).

(3) I am not sure how to obtain an IP number and port for this. The ideal
situation is done at install time, involves no user knowledge, interaction
or config, and does not conflict or destroy any existing settings (hey I
can dream can't I?!).  Of course there are config overrides for problem
installs. But just for the generic simple easy working case, I still have
no idea how to proceed getting a workable IP/PORT for this.

Current advice is to use localhost 127.0.0.1 and cycle through port
numbers above 50000 until an available one is found. Seems kinda flakey to
me. But I do not know what I am doing in this regard.

Any hints or links greatly appreciated.,

Thank you.

===
PS: The recent discussion about a single global variable to track
instances may actually be a solution. The program already does this in a
much more complex way: session records are created, and these are also
used for handling resource conflicts and so forth.

The essential difficulty is that I am a stupid programmer, the programs
are large and complex, they run on windows networks in real
installations... so invariably, an instance will crash. Leaving the
session table with orphaned entries.

A simple counter program is not so likely to fail. Yet also avoids
TCP/IP/mailslots and other windows IPC issues.

However. There comes a time when exclusive access to some operation is
absolutely required, and the only fail-safe way to ensure every session
record is an active one, is to talk to the running sessions. A boring
delay is involved as each process must be polled.

Cheers




[EMAIL PROTECTED] wrote:
>> Happy New Year!
>> Delphi 5
>> Windows local area network.
>> How do I determine if any other instances of my EXE are running on the
network?
>> Each is started from the same common folder.
>> My program already manages a "session table". But sometime my program
fails and exits abnormally, so the session table entry does not get
deleted.
>> I wish for a routine that would poll or otherwise determine somehow "in
real time" if there are truly active instances of the same EXE alive on
the network.
>> Not sure which set of windows API calls I should be looking at. Many
thanks in advance.
>
> Haven't we already answered this question or something like it before?
>
> There is no Windows API to do what you want.  The only way you can come
close would be to have a central server that all instances of your EXE
connect into - probably over TCP/IP.  Then you can send whatever data
you want over the connection as long as the server handles it.  Throw in
some sort of keep-alive that gets sent every 30 seconds or so to keep
the underlying socket from disconnecting.  Then when you want
> information in "real-time", you connect into the server with a special
application that retrieves the client information via a broadcast of
some sort to which clients respond and the server collects and sends to
the special client.
>
> That's the only way I know of to get close to getting real-time
responses.







Reply via email to