How to Start a Windows-Based App Directly from MS-DOSLast reviewed: July 22, 1997Article ID: Q74887 |
3.00 3.10
WINDOWS
kbprg
The information in this article applies to:
SUMMARYIt is possible to create a Windows-based application that can be started directly from the MS-DOS prompt. For example, the KILLERAP application may be written so that when KILLERAP is typed at the MS-DOS prompt, Windows is loaded and KILLERAP run. However, some specific programming is required to perform this task. Otherwise, enhanced mode Windows will produce a "Memory Segmented" error message. This article discusses the techniques required.
MORE INFORMATIONThe "Memory Segmented" error message is caused by the fact that the application that spawns Windows remains in memory when Windows loads. There is a straightforward way to work around this complication. Replace the standard WINSTUB.EXE program, provided with the Windows Software Development Kit, with a custom program tailored to the application. The following sample WINSTUB program loads the string "win notepad" into the keyboard key buffer. Then the program terminates and is removed from memory. The keystrokes in the key buffer are played back by the hardware to MS-DOS. This starts Windows and runs the program. This sample code requires Microsoft C version 6.0 or later to compile because it uses inline assembly code. A similar program may be written with the Microsoft Macro Assembler (MASM) version 5.1 or later.
Sample Code
void main(void){ char szExecLine[] = "win notepad\r"; int iIndex; char cChar; for (iIndex = 0; iIndex < sizeof(szExecLine); iIndex++) { cChar = szExecLine[iIndex]; _asm { mov ah, 05h mov ch, 0 mov cl, cChar int 16h } }}
|
Additional reference words: 3.00 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |