Author Topic: Project with no interface ?  (Read 2527 times)

AssemblyChallenge

  • Member
  • **
  • Posts: 110
Project with no interface ?
« 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.

rrr314159

  • Member
  • *****
  • Posts: 1382
Re: Project with no interface ?
« Reply #1 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.
I am NaN ;)

AssemblyChallenge

  • Member
  • **
  • Posts: 110
Re: Project with no interface ?
« Reply #2 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:

dedndave

  • Member
  • *****
  • Posts: 8807
  • Still using Abacus 2.0
    • DednDave
Re: Project with no interface ?
« Reply #3 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

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Project with no interface ?
« Reply #4 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:
Code: [Select]
;==============================================================================
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

  • Moderator
  • Member
  • *****
  • Posts: 285
    • Easy Code
Re: Project with no interface ?
« Reply #5 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
EC coder