Link to home
Start Free TrialLog in
Avatar of rafaelrgl
rafaelrgl

asked on

monitoring my application if is open or not.

so, I'm trying to build a application to my cybercafe, so I have a client application in my clients computer, but sometimes happening that, somebody try to close this client application to denny my server to monitoring this machine.

what I want to do is create other application that monitoring this client application if is open or not, if is not then open it.
by the way, this application have to be hide from taskbar.

this way, my clients is not going to be abble to denny my application to close the pc when him time is done. So they have to pay for more time.
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

what about making your monitoring application a service instead?
it's less obvious, and unless the logged on user has the rights, they cannot close it
at the very least, you could make your "check if my app is running" a simple service, thatruns your app if it is not running.
(much like the Firebird Guardian Service and Interbase Guardian services do)
all you would need to do for example is :-
if FindWindow('TfWMonitorApplication', 'Cyer monitor') = nil then
  winexec('c:\myapp.exe'); // runi t because it is not running

1 other method would be to not let your application close
e.g you need a password to close it

in the Form's "OnCloseQuery" event you could add
CanClose := (inputbox('Close', 'Password', '') = 'secret');

you would then just need to catch the wm_queryendsession message so that windows could close your app if it needed to shut down.
but if you manually close the machines down you can just enter the password
Avatar of rafaelrgl
rafaelrgl

ASKER

if FindWindow('TfWMonitorApplication', 'TEST') = nil then
begin
   showmessage('program is not running');
end;

I try to do like this above and show this error:   Operator not applicable to this operand type
sorry
if FindWindow('TfWMonitorApplication', 'TEST') = 0 then
...
it returns a handle
well, my application on trayicon and hide. When I try to test the function if my application is open or not, the function shows the message, something is wrong.

if FindWindow('TfWMonitorApplication', 'TEST') = 0 then
begin
   showmessage('is running');
end;
SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Build
  [Error] FrmMonitor.pas(34): Undeclared identifier: 'TProcessEntry32'
  [Error] FrmMonitor.pas(37): Undeclared identifier: 'CreateToolhelp32Snapshot'
  [Error] FrmMonitor.pas(37): Undeclared identifier: 'TH32CS_SNAPPROCESS'
  [Error] FrmMonitor.pas(38): Missing operator or semicolon
  [Error] FrmMonitor.pas(39): Undeclared identifier: 'Process32First'
  [Error] FrmMonitor.pas(42): ')' expected but identifier 'szExeFile' found
  [Error] FrmMonitor.pas(60): Record, object or class type required
  [Error] FrmMonitor.pas(62): 'END' expected but end of file found
 
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you could use code injection to prevent any application from being closed. but thats rather a bomb and should be handled very carefully. do you compile your "watching software" yourself or is it a third party one?

another way to solve the problem is the question "HOW do the users kill your program"? you can disable taskmanagers, only few people know the commandline...