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
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.
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.