0
Answer

External Application Check

I am attempting to write a program that will manage an external application state.  The external application accepts information which is passed to it and runs a process and then exits.  However, I would like to catch if an error has occurred in the application by way of identifying dialog/prompt boxes belonging to the application.

I have tried the GetWindow, EnumChildWindows API but they do not seem to identify the dialog/prompt windows.  I was using the following:

public delegate bool WindowEnumDelegate (IntPtr hWnd, int lParam);

foreach (Process thisProcess in Process.GetProcesses())

{

    if (thisProcess.ProcessName = "prsPDFp")

  {

        WindowEnumDelegate del = new WindowEnumDelegate(WindowEnumProc);

         EnumChildWindows(thisProcess.MainWindowHandle, del, 0)

  }

}

public static bool  WindowEnumProc(IntPtr hWnd, int lParam)

{

     StringBuilder bld = new StringBuilder(256);

     GetWindowText (hWnd, bld, 256);

     string text = bld.ToString();

     MessageBox.Show (text, "WindowEnumProc");

     return true;

}

The GetWindow method I have found looks loops through the child windows, but the prompt and dialog boxes do not show up - it's as if they are not childs of the main window - is this the case, if so, how can I get the information for them.

Any help/comments welcomed.