Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

monitoring my application if is open or not.

Posted on 2006-07-04
8
Medium Priority
?
201 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:rafaelrgl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17038958
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
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17039028
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
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 17039125
sorry
if FindWindow('TfWMonitorApplication', 'TEST') = 0 then
...
it returns a handle
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:rafaelrgl
ID: 17039405
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;
0
 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 800 total points
ID: 17039629
ahh ok, because it is hidden you will need to look for it another way

try this

function IsProcessRunning(ExeFileName: string): boolean;
    const
        PROCESS_TERMINATE=$0001;
    var
        ContinueLoop: BOOL;
        FSnapshotHandle: THandle;
        FProcessEntry32: TProcessEntry32;
    begin
        result := False;
        FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
        FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
        ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
        while (not Result) and (integer(ContinueLoop) <> 0) do
        begin
            if (StrIComp(PChar(ExtractFileName(FProcessEntry32.szExeFile)), PChar(ExeFileName)) = 0)
              or (StrIComp(FProcessEntry32.szExeFile, PChar(ExeFileName)) = 0)  then
                Result := True;
            ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
        end;
        CloseHandle(FSnapshotHandle);
    end;

procedure TForm1.Button1Click(Sender: TObject);
    begin
        if IsProcessRunning('Notepad.exe') then ShowMessage('yes'); // replace notepad.exe with the path and filename of your tray application
    end;
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 17039893
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
 
0
 
LVL 16

Accepted Solution

by:
CodedK earned 1200 total points
ID: 17039899
Hi... TheRealLoki  why "TfWMonitorApplication" ? (This is the handle for Mozzilla ?)

FindWindow(class name : string, window name : string)

So because you dont have the handle just do this:

if  FindWindow(nil, 'The caption of your application')=0 then
run it.... (with ShellExecute or winexec)


0
 
LVL 12

Expert Comment

by:AmigoJack
ID: 17040569
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...
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

704 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