Board index » delphi » Checking existing instance of running EXE

Checking existing instance of running EXE

Is there some way to make Delphi programs check whether
they are already running and take appropriate actions
if so?

Thanks.

Gary Tse.

*---------------------------------------------
*  No more spamming please!
*  Remove DO_NOT_SPAM_2_ to reply.
*---------------------------------------------

 

Re:Checking existing instance of running EXE


Quote
Gary Tse wrote:
> Is there some way to make Delphi programs check whether
> they are already running and take appropriate actions
> if so?

> Thanks.

> Gary Tse.

> *---------------------------------------------
> *  No more spamming please!
> *  Remove DO_NOT_SPAM_2_ to reply.
> *---------------------------------------------

Yes. It is.

For example:
 1)use FindWindow( Window_Class_Name; Window_Caption ) function to check if
    specified window has been already created, and if returned value <> 0 ( the
handle
    of the window ), You can do everything You whant with it.
 2)specify any unique message( I use RegisterWindowMessage in such cases ) in
both
    applications( current and that, what You are looking for );
    When current application will run, post this message to every currently
existing window
    ( use PostMessage with HWND_BROADCAST as window handle ) and wait for
    reply( for example if message WM_AREYOUHERE has been posted, the second
    application should post message WM_YESIAM ; don't forget to register all
messages
    in both programs as the same strings of the same case!!! )

---------
Sincerely,
Vadim Gurevich
M&M Data Systems, Ukraine
e-mail: va...@mmdata.kharkov.ua

Other Threads