tags:

views:

228

answers:

1

Is there a way to create a service using C# able to check if this client is Open?

I need to work a way to automate that checking.

+2  A: 

If the window is open (does not need to be in focus) You could use FindWindow window call from the user32.dll to check on the window. Cut up the code below and place in the correct places (for the using, define of the dllimport, and the actual code). This will tell you if the window is open, there is a LOT more you can do with windows calls.

using System.Runtime.InteropServices;

[DllImport("user32.dll", EntryPoint="FindWindow", SetLastError = true)] static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

IntPtr hWnd = FindWindowByCaption(IntPtr.Zero,"Cisco vpn title here");
if(hWnd.ToInt64() == 0){
    Console.WriteLine("ERROR Could not find cisco vpn.");
}else{
    Console.WriteLine("Handle found");
}
Infamy