C++ Daemon?

Sep 15, 2010 at 12:31am
I can't seem to find out how to write a background/system process that you can't see...
Btw I'm using Windows... I see their/your server thinks I'm using Linux...
Sep 15, 2010 at 12:58am
Just don't make a window...?
Sep 15, 2010 at 1:05am
But then it shows up in CMD/Terminal
Sep 15, 2010 at 1:24am
Filetestingman wrote:
I see their/your server thinks I'm using Linux...

...maybe the server is trying to hint something..? ;o)
Sep 15, 2010 at 1:28am
But I don't want Linux. I mean I do, but not now. It keeps giving me Linux suggestions.
Back to the question...
Sep 15, 2010 at 5:43am
For Windows service, there are some Windows specific API you need to call in your application so that it don't show up in CMD/Terminal.

Basically you control your Windows Service via the Control Panel -> Services. I believe there is a ServiceManager that manages all the services. So your program must behave well and react according to the ServiceManager calling your program methods.

Just imagine ServiceManager as a container application and all services "reside" inside this container. Therefore all services must behave when say ServiceManager call you to "stop" "pause" "restart", your service methods must implement accordingly.
Sep 15, 2010 at 7:25pm
I know what the services.msc is/does, but that's just for automatically running programs and other things
Sep 15, 2010 at 8:12pm
I havn't even watched this yet but it might be my answer: http://www.youtube.com/watch?v=bD93DX8Ph-c
Umm... No.
Maybe this will work:
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
int main()
{
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );
// Some code
return 0;
}
Last edited on Sep 15, 2010 at 8:33pm
Sep 16, 2010 at 9:49am
I know what the services.msc is/does, but that's just for automatically running programs and other things


Isn't that what you want ? Auto-run the program and it stay on there acting like a background process until you use Control Panel -> Services to stop or even remove it.

You mean the Windows service is not equivalent to background process? A lot of device drivers we install also uses this feature.

Or you are looking at putting your program in some startup folder ? Then you need to check another set of Windows API that allow you to "nest" your application in the taskbar below right.

Sep 16, 2010 at 4:54pm
No, I just wanted to hide the black console window/cmd/terminal.
Services will help with keeping it running though.
Sep 16, 2010 at 5:13pm
If you don't want the console window, create a Win32 application.
No window will be created until you call CreateWindow.
Sep 16, 2010 at 5:25pm
Ohhhhhh, I think I can do that in MVSC++EE(Microsoft Visual Studio C++ Express Edition)
Thx everyone, I think I got it now

Adiós
Bye!
Topic archived. No new replies allowed.