Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting a hidden C++ program

I am creating a C++ program with Visual Studio 2010 that is supposed to run on the background of my machine.

Therefore when I start it, I shouldn't see the CMD screen while it is running. How can I do this? Do I have to use the Win32 API or a normal C++ program will suffice?

Please note that my program has no GUI at all.

like image 694
Felipe Avatar asked Nov 30 '11 19:11

Felipe


1 Answers

Use WinMain() :

#include <windows.h>

int WINAPI WinMain(HINSTANCE inst,HINSTANCE prev,LPSTR cmd,int show)
{
  // program starts here
  return 0;
}

// int main()  <-- remove main() 

Then ake sure your project settings are set so that you build a "Win32" program and not a "Console" program.

enter image description here

Edit: As @Sehe points out, winMain may not be necessary, although I am not quite sure where this option lies.

like image 70
FailedDev Avatar answered Oct 03 '22 16:10

FailedDev