LagAbuse.com

Unofficial Section => Programming => Topic started by: JokeBOx on February 02, 2012, 18:11

Title: [Tutorial] Make applications run as a service C++
Post by: JokeBOx on February 02, 2012, 18:11
In C++ it is possible to hide the window and make the program run as a background service, luckily this is extremely easy to do.

First we add this as our first line of the program.

Code: [Select]
#define _WIN32_WINNT 0x0500
Then in our main() function, we add.

Code: [Select]
HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd, SW_HIDE); 

This will result in our program becoming hidden

Here we have an example application that will run in the background for 10 seconds doing nothing.

(http://img31.imageshack.us/img31/5909/applrunasservice.jpg) (http://imageshack.us/photo/my-images/31/applrunasservice.jpg/)

Enjoy.