Ask the Expert

How can we work around Win2k not having a "warn if still active" option to uncheck so we can shut do

We have an application that in some processes needs to spawn another task via the shell command. When these shelled tasks happen to be DOS applications, our software will decide when it is time to shut them down via the SendMessage() API call and the WM_CLOSE transaction. This works fine under Win95, Win98, WinME as long as the DOS window property "warn if still active" is unchecked.

My problem is with Win2000. Its command prompt window property page doesn't have a "warn if still active" option to uncheck and so we are unable to shut it down programmatically.

Is there a work around, another API call, or technique for one application to programmatically shut down a command prompt window?

    Requires Free Membership to View

What an interesting dilemma. After poking around a bit, I'm not really sure there is a clean way to do it. The best piece of advice came from an article on the Microsoft KnowledgeBase, "HOWTO: Terminate an Application "Cleanly" in Win32", (http://support.microsoft.com/default.aspx?scid=kb;EN-US;q178893). Since you control the startup of those DOS applications you can start them in their own copies of NTDVM.EXE, the NT DOS Virtual Machine, where all 16-bit applications run. When it's time to kill the app, you can probably just kill that specific instance of NTVDM.EXE you spawned with TerminateProcess. It's not pretty to call TerminateProcess, but it will work!

This was first published in December 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: