No Window

How can I make a program with out a window not even a console window just something that runs in the background? If you could help that would be great thanks in advance
You can't.

But you can hide your window. If you start a GUI project and remove the WS_VISIBLE attribute from the dwStyle argument to CreateWindow[Ex]().

You can also just ShowWindow( my_hwnd, SW_HIDE ); when your application first starts.

Hope this helps.
..umm, use WinMain()? When using that, unless you go and create a window, nothing should show up..
Yeah just use WinMain() as your entry point and nothing will show up.
Surely there must be some way of doing this without "cheating"? I say cheating because using WinMain() and not creating a Window isn't doing it properly; it's almost a coincidence that it works. And it might not work -- the compiler might decide to make a console window instead.

As Duoas said, you can use SW_HIDE; but according to Microsoft you may have to call ShowWindow twice with the same parameters (which is ridiculous).

If you run your program as a service, by calling it with the -i switch (I think) to run it as such...
I'm sorry but that just doesn't make any sense at all to me.

Logically a program would start at an entry point doing nothing. For a window to be created you must call functions which build the window.

I have no idea where you get the idea that this is, "cheating".

I could call all of your applications that run on top of an operating system "cheating" then. Your operating system is doing a lot of the work for you.

Windows has a CONSOLE and GUI subsystem. If you want to create a daemon (process that runs in the background) I would have the compiler build the application with the GUI subsystem value without calling functions that specifically allocate, register, and create a window.
Last edited on
Point made :P

But I still think you should use SW_HIDE as opposed to just not defining a Window.

Unless you literally want a background task.

The only problem with SW_HIDE is that the window/console window shows for a little while; just a second, but if you were using this maliciously it wouldn't work. Then again, I suppose that's a good thing.
Last edited on
> You can't.

???
If you don't create any window , you won't have any window !
All windowless Win32 apps are done like this
Read the Petzold for Win32 basics...
Topic archived. No new replies allowed.