Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application Running Detection ...

Status
Not open for further replies.

Finisher

Programmer
Jan 10, 2002
23
0
0
PH
how can i detect the applications being run in a client/server pc??? using delphi?

please advise, thanks in advance...
 
you either have to enumerate all windows which will give you visible running apps, or you have to enumerate all processes which is more detailed but more difficult to do (in some respects) and some of the process names aren't indicative of the parent application that process belongs too.
There are several components out there (check DSP) which make it easy to do it either way
 
By using API calls (their easy, just add ShellAPI to your uses clause) the following will work...

{ attempt to create a named nutex }
CreateMutex(Nil,False,'AppName');
{ check to see if it was created }
if ( GetLastError = ERROR_ALREADY_EXISTS ) then begin
{ inform the user only one instance is allowed }
MessageDlg('App is already running...' + CHR(10) +
'Shutting down ',mtError,[mbOk],0);
{ send a broadcast message to all windows, your app will recognize it and show itself }
SendMessage(HWND_BROADCAST,RegisterWindowMessage('AppName'),0,0);
Application.Terminate;
end;

Just change 'AppName' to your applications name - found in Project, Options, Application, Title.

Let me know if you'd like more info.
 
hi

CreateMutex is used to check if your own app is running already. If you want to check for apps like XL or Word you need something like FindWindow.

lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top