views:

47

answers:

5

For example, in C#, you can make a program run without the black screen appearing...so I thought: since anything you can do with .NET you can also do with Win32, maybe there's a solution.

Any ideas?

+2  A: 

The console window appears when the program is linked with /SUBSYSTEM:CONSOLE which is the default if you haven't asked for anything else.

If you want it to be a "Windows App" i.e. "make GUI contributions" including being invisible, link with /SUBSYSTEM:WINDOWS. However, you will need a WinMain function rather than the usual main function.

Ninefingers
How can I do this? I entered:#pragma comment (linker, "/SUBSYSTEM:WINDOWS"), and replaced "int main()" with:int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow), but it still doesn't work...
Claudiu
Two ways, as @Alex Farber suggests, you can do it via Visual Studio's properties editor - you're looking in Linker Settings for a C++ project. The other way is if you're building by hand, when you type "LINK /out:exename.exe obj1.obj obj2.obj" append /SUBSYSTEM:WINDOWS to that line.
Ninefingers
You don't need to change main function to WinMain for this. At least, don't have to.
Alex Farber
Thank you, indeed WinMain() wasn't necessary...i think it wasn't working for me before because i was working on an older compiler...I used Visual Studio and it worked now :-)
Claudiu
+1  A: 

Open Project - Properties, and set /SUBSYSTEM linker option to WINDOWS.

Alex Farber
A: 

Have a look at this link here which shows the code on how to make the window hidden...

tommieb75
A: 

function:

start /b [command]

VeeWee
A: 

I have a header file "MainEntryPoint.h" that contains the following text:

#pragma once
#if defined _MSC_VER 
  #if !defined _WINDLL
    #pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
  #endif
#endif

I #include this file in the main.cpp file of any project that

  • needs to be a windows rather than console app
  • As I do cross-platform work I prefer to use the standard (main()) C / C++ entry point for all my projects.

(The guard macro's automatically ensure it only applies to DevStudio builds and excludes messing with the entry point when building a dll).

Chris Becke