News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Project with no interface ?

Started by AssemblyChallenge, February 13, 2015, 05:46:11 AM

Previous topic - Next topic

AssemblyChallenge

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.

rrr314159

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.
I am NaN ;)

AssemblyChallenge

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:

dedndave

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

MichaelW

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

Well Microsoft, here's another nice mess you've gotten us into.

rsala

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
EC coder