Hi Everyone -

I am in the process of creating a windows service that will monitor
for a dialog to be displayed, and when it is displayed, the service will
send a keypress to it...

This all works fine for a .exe application, but when i place the code
in the service shell, it never finds the window in order to close it!!!


[DllImport("USER32.DLL", SetLastError=true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);



IntPtr XXXErrorWindowHandle = FindWindow(null, "XXX");
while (done == false)
{
if (XXXErrorWindowHandle != IntPtr.Zero)
{
SetForegroundWindow(XXXErrorWindowHandle);
SendKeys.SendWait("~");
ReturnStatus = true;
}

XXXErrorWindowHandle = FindWindow(null, "XXX");
done = (XXXErrorWindowHandle == IntPtr.Zero);
}



Like i said, the application works fine as an .exe
but when inserted into my service, it never finds the XXX window....

I have tried with interact with desktop on and off - same results!!

please advise


take care
tony