Why does this happen

  • Thread starter Thread starter Ian Frawley
  • Start date Start date
I

Ian Frawley

Hello

I have written some code that I can run as an app or as a service. Its role
is to monitor the Process.Responding of an executing application. When it
runs as an app it gets the MainWindowHandle and also detects whether the app
is responding or not. However if I run my code as a Windows Service it
doesn't get the MainWindowHandle and always returns true on the
Process.Responding, whether it is or not. My first thought is that a Windows
Service is/might be executing on a different layer to the GUI of the app
being monitored but that is a guess.

Does anyone know why this may be happening and also a possible work around?

Cheers
 
That would be my first thought also. You could probably use the EnumWindows
api to get the hWnd.
 
in message
That would be my first thought also. You could probably use the EnumWindows
api to get the hWnd.

Hi thanks for the response I am starting to panic a bit really as this fly
in th ointment could really mess up my design model *gulps*
I am still kinda learning C# so have you got any good examples or URL's for
the Enum Windows api?

Thanks

Ian
 
in message
That would be my first thought also. You could probably use the EnumWindows
api to get the hWnd.

I have managed to find a way to get the hWnd but I am not sure how this will
help me to get the Process.
Can you help me?

Many thanks

Ian
 
Mini break through! It seems that you have to make the service run as a
system account and interact with the desk top.
The problem is that I then start to have database connection issues, which I
can iron out, but more importantly running as a system account prevents me
from monitoring remote processes gulp.
Can you have a service that uses a specific user account and also interacts
with the desktop?

Ian
 
Yes because having a SYSTEM process runing with a UI is good for security,
all I have to do is EnumWindows, FindWindow, get the hWnd, and then do
SetWindowLong and PostMessage to my hearts content with subclassing and
message injecting and I get privlidge esclation to SYSTEM level :D

ROOTED and OWNED:

Smooth.
 
Nah the system process is actually a SERVICE not a PROCESS. It is
responsible for monitoring various applications with UI's. The Apps running
with UI's do NOT use a SYSTEM account. Its the service that monitors them
that I have unfortunatley had to make use a system account so that it can
interact with the desktop and therefore check the
System.Diagnostics.Process.Responding against the Apps with UI's.

Hope this makes sence.

Ian
 
Back
Top