Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have the need to configure a Windows XP Embedded system in order to dismiss modal MessageBoxes with a default reply.

I am aware of the EnableDefaultReply feature but I need to be more selective on which MessageBoxes to dismiss or select the default reply on some criteria (example: name of the window).

My biggest problem right now is that:

  • If do not enable the EnableDefaultReply feature: some background services pop up dialogboxes which are never dismissed and block the application
  • If I enable the EnableDefaultReply feature: I am no longer able to logon to the system if another user is logged in (a MessageBox popups asking if you want to steal the logon and the default answer is NO).

Do you have any experience you can share with this problem?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I wrote a C# app back in .net 2.0 days, so that should work since embedded can get 3.0

This is ugly code from when I was a beginner, but you could write something up that uses the api calls found here and spends most of its time sleeping unless it sees a window that it needs to kill. Otherwse you might need to license an application that essentially does the same thing. :) Also, if you can't put .net on there, these are standard windows calls so any c++ programmer in the shop could put this together for you in about 2 hours.

using System;
using System.Collections;
using System.Threading;               
using System.Runtime.InteropServices;   //  Dllimport

namespace osconfig
{
/// <summary>
/// Summary description for WindowHiding.
/// </summary>
public class WindowHiding
{
    ArrayList windowNames;
    private const int sleepTime = 100;

    //  For findind the windows dialogs that popup when devices are detected
    [DllImport ("user32.dll")]
    public static extern int ShowWindow (IntPtr hWnd, int nCmdShow);

    [DllImport("User32.dll", CharSet=CharSet.Auto)]
    private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

    //private const int SW_SHOW = 5;
    private const int SW_HIDE = 0;
    private const short WM_COPYDATA = 74;

    public WindowHiding(ArrayList wNames)
    {
        this.windowNames = wNames;
    }

    //  Spin a thread that hunts down and hides windows
    public void hideWindows()
    {
        //  Run until we are told to stop
        while (true)
        {
            IntPtr foundHardwareWindowHandle;
            int result;

            //  Look for each of the window names.
            foreach (string wName in this.windowNames)
            {
                try 
                {
                    foundHardwareWindowHandle = FindWindow(null, wName);

                    if (foundHardwareWindowHandle.ToInt32() > 0)
                    {
                        //  Found it.  Hide it.
                        result = ShowWindow(foundHardwareWindowHandle, SW_HIDE);
                    }
                }
                catch 
                {
                    //  Do nothing...
                }   
            }

            //  Go to sleep
            Thread.Sleep(sleepTime);
        }
    }
}

}

share|improve this answer

This is not a direct answer to your question, but the suggestion of a possible work-around.

When I was working with Windows XP Embedded machines, I always installed Ultra VNC for remote access. It meant that I could take control of a machine without locking out the local operator. It also meant that I could just connect to watch what was happening. This was really useful when talking customers or field service engineers through problems they were having.

The other thing I like about UVNC is that if encryption is enabled host side, you can be sure that no-one will ever be able to accidentally make an insecure connection.

share|improve this answer
    
Good point. Anyway, in my experience VNC performances over the internet are poor when compared to RDP. Thanks :) –  Pokot0 Mar 31 '10 at 10:40
    
More recent versions of VNC, such as UltraVNC and NX support many more options for optimisating the connection. From High bandwidth, low latency, low cpu usage for use on a LAN, to High compression, high cpu usage for use over slow internet links. –  Mark Booth Nov 11 '10 at 16:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.