News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

avoid console screen to run EXE

Started by Dalbir, December 14, 2009, 08:24:12 AM

Previous topic - Next topic

Dalbir

Hi There,

How can we remove or avoid the console screen while run the exe. We create Exe of simple program. When we run the exe directly. Then console screen first come and after that program's output display. We want to run the exe as other application in window.

Thanks

TNick

If you have only one program that you need to show both a console and a GUI:
- Use /SUBSYSTEM:WINDOWS option in linker.
- at program start, call AllocConsole to get in console mode
- call GetStdHandle to get the handles
- build the GUI hidden
- use FreeConsole to get rid of the console
- show the GUI


If you need to show the output of some program that runs in console mode (say, ml.exe):
- create two pipes (see CreatePipe function in windows)
- use GetStartupInfo to fill a STARTUPINFO structure
- alter following members:

    mov     eax,                        hWriteEcho
    mov     ecx,                        hReadCmd
    mov     St_INFO.hStdOutput,         eax
    mov     St_INFO.hStdError,          eax
    mov     St_INFO.hStdInput,          ecx
    mov     St_INFO.dwFlags,            STARTF_USESHOWWINDOW + STARTF_USESTDHANDLES
    mov     St_INFO.wShowWindow,        SW_SHOW

- use CreateProcess to start up the exe
- don't forget to close one end for each pipe

    INVOKE  CloseHandle,                hWriteEcho
    INVOKE  CloseHandle,                hReadCmd


Nick

Dalbir

int main( void )
{

   char *msg = "A to Z of C \r\n$";  /* $ is the null terminator
      in assembly */
      clrscr();
   asm {
    MOV AH, 9;
          MOV DX, msg;
          INT 21H;
       }
       getch();
   return(0);
}

This is the simple program. we build these program using turbo c. And got obj and exe file. We have Tlink  linker. That does not support /subsystem:windows option. What is the way by this?

is there any way in the link  from masm. To build obj file from the turbo compiler. We try  that but not successful.  We got following error.

C:\masm32\bin>link /SUBSYSTEM:WINDOWS asmtest.obj
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

asmtest.obj : warning LNK4033: converting object format from OMF to COFF
asmtest.obj : fatal error LNK1190: invalid fixup found, type 0x0001



dedndave

i think the INT 21h call requires a console window

FORTRANS

Hi,

   As dedndave says, the "INT 21H" is the instruction that
invokes the interrupt for the MS-DOS system functions.
The "MOV AH, 9" is requesting function 9, which is the 'console
string output' or 'string output' function.  DOS programs pretty
much are always 'console' programs when run under Windows.

HTH,

Steve N.

MichaelW

Dalbir,

Under Windows, for a 16-bit DOS EXE your choices are to run it in a console window or run it full-screen. To see the possibilities, in Explorer right-click the EXE and select properties from the context menu.
eschew obfuscation

Dalbir

Thanks & Hello to all,

you are right. Dos function must always console.

But why it display two console on double click the exe.

you may  run cmd.exe to open command prompt in window. How it run? Just double click on the exe. A console ( only one console ) promptly open. But when we run our exe. A black console  screen with blinking cursor open  first and after a second our program's output in new console screen ( first screen automatically close).

one thing more,  we try the properties of exe on right click. There is a program tab in properties. And a check box Close on exit. If we uncheck  it then the first window doesnot close. we close it manually.

MichaelW

Try posting your code, and the command lines that you are using for ML and Link.
eschew obfuscation

dedndave

it sounds as though you may be trying to write a GUI app with 16-bit code
or, the console app calls AttachConsole - which you do not need
because you are writing a C program, we do not know what all the initialization code looks like
start out with a simple console mode ASM program, and work your way up from there
you will probably want to write 32-bit apps for GUI mode

in the following link, you will find an attachment with a 16-bit and a 32-bit "Hello World" programs
if i remember correctly, i also included the batch files to perform assembly

http://www.masm32.com/board/index.php?topic=12621.msg97236#msg97236

FORTRANS

Hi,

   If running Windows 2000, XP, or their ilk, the native
console is CMD.EXE and DOS programs are then run by
COMMAND.COM.  Normally the switch between those
is seamless.  You may have some program properties
set to a non-default setting

Steve N.