1

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?

David Wengier
  • 10,061
  • 5
  • 39
  • 43
Claudiu
  • 2,124
  • 4
  • 26
  • 36

4 Answers4

2

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.

Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
  • 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 Aug 18 '10 at 12:06
  • 1
    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. –  Aug 18 '10 at 12:16
  • You don't need to change main function to WinMain for this. At least, don't have to. – Alex F Aug 18 '10 at 12:25
  • 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 Aug 18 '10 at 13:14
1

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

Alex F
  • 42,307
  • 41
  • 144
  • 212
0

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
  • 34,244
  • 12
  • 79
  • 148
-1

function:

start /b [command]

VeeWee
  • 560
  • 1
  • 5
  • 19