The MASM Forum

Projects => Easy Code IDE 32/64-bit => Topic started by: AssemblyChallenge on February 13, 2015, 05:46:11 AM

Title: Project with no interface ?
Post by: AssemblyChallenge on February 13, 2015, 05:46:11 AM
Hi all.

Most part of the stuff I do are in Console mode but this time I need to create a very small project with no interface at all. Some sort of house keeping program that starts, do the job and quits, no need for dialogs, messages, etc. The NT Service is simply overkill for the matter.

I was thinking about the Console... but removing the console too :biggrin:. Any advice ??

Thanks in advance.
Title: Re: Project with no interface ?
Post by: rrr314159 on February 13, 2015, 06:12:34 AM
There's probably a better answer - but one thing you can do, change the link subsystem option from "console" to "windows", then don't make any windows in the application. No console or window will pop up, the exe just "starts, does the job, and quits". I learned this by using "/subsystem:windows" and forgetting to show a window: nothing visible happens.
Title: Re: Project with no interface ?
Post by: AssemblyChallenge on February 13, 2015, 07:27:19 AM
Thank you very much.

That seems to be working. For all the folks using EasyCode, here is how to do it:

* Create a new Classic console application (exe) project.
* Save your project.
* Click on Project menu, then Project properties.
* In the dialog, add "/subsystem:windows" on Linker options.
* Click Ok, you are done.

If Rsala has some more advices, they are welcomed.  :biggrin:
Title: Re: Project with no interface ?
Post by: dedndave on February 13, 2015, 07:56:37 AM
that is essentially a good answer
however, some applications may require a window so that messages may be received
there are a couple ways to do that, as well
one way is to use a "message-only" window
another is to size the window as 0x0 pixels, or to place it off-screen
you can also make a window invisible by having no border or caption bar, and using NULL as it's color
Title: Re: Project with no interface ?
Post by: MichaelW on February 13, 2015, 11:30:54 AM
A crude, and I think near minimal, MASM32 example that uses a message-only window with a timer:

;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data?
    msg       MSG         <> 
    wcx       WNDCLASSEX  <>   
.data
    counter   dd          0
    className db          "timer_class",0
.code
;==============================================================================
TimerProc proc hwnd:DWORD,uMsg:DWORD,idEvent:DWORD,dwTime:DWORD
    inc   counter
    .IF counter > 5
        invoke KillTimer, NULL, 1
        exit
    .ENDIF 
    MsgBox hwnd,0,"Timer",0
    ret
TimerProc endp
;==============================================================================
start:
;==============================================================================
    mov     wcx.cbSize, SIZEOF WNDCLASSEX
    invoke GetModuleHandle, NULL
    push    eax
    pop     wcx.hInstance
    mov     wcx.lpszClassName, OFFSET className
    invoke RegisterClassEx, ADDR wcx
    invoke SetTimer,NULL,1,1000,TimerProc
    invoke CreateWindowEx, 0,0,0,0,0,0,0,0,HWND_MESSAGE,0,0,0
  msgLoop:
    invoke GetMessage, ADDR msg, NULL, 0, 0
    .IF eax > 0
        invoke DispatchMessage, ADDR msg
        jmp msgLoop       
    .ENDIF 
    exit msg.wParam
end start

Title: Re: Project with no interface ?
Post by: rsala on February 20, 2015, 10:02:47 AM
Hi AssemblyChallenge,

Another way to create a project with no "visible" interface, specially if you need to process some messages, is creating a visual project and setting the Visible property of the window to FALSE. The interface will not visible and you wiil be able to process all messages you need. When the job is done, just send a WM_CLOSE message to the window.

Regards,

Ramon