Government Security
Network Security Resources

Jump to content

Photo

C++ How To Hide Console Window

- - - - - c++
  • Please log in to reply
8 replies to this topic

#1 br0k3nl1m1t

br0k3nl1m1t

    Private

  • Members
  • 2 posts

Posted 23 July 2007 - 08:25 AM

Hi!I am new and i start with a question. How can i hide the console window that appears when i start the program? I am using vc++ 2005 unmanaged. Thank you in advance

#2 hm1ch

hm1ch

    Corporal

  • Members
  • 176 posts

Posted 23 July 2007 - 08:40 AM

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
int main()
{
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );

return 0;
}

1 min with google !
"Member of #rainbowcrack @ irc.plain-text.info"
Best online MD5/LM/NTLM webcracker - http://www.plain-text.info

#3 br0k3nl1m1t

br0k3nl1m1t

    Private

  • Members
  • 2 posts

Posted 23 July 2007 - 11:42 AM

Ok thank you very much. I had already seen this code but i had forgotten to insert the line "#define _WIN32_WINNT 0x0500" :unsure: .

#4 Paul

Paul

    Master Sergeant

  • Members
  • 849 posts

Posted 23 July 2007 - 12:12 PM

Some windows compilers like Visual C++ and MinGW offer __argv and __argc
to access the command line arguments in "WinMain-applications".

Convert your program to WinMain and use __argv and __argc to access command line parameters.
Give it up for the IPB news bot.
-_-

#5 s134k

s134k

    Sergeant

  • Members
  • 217 posts

Posted 23 July 2007 - 09:40 PM

just thought I'd add that if you're planning on switching to a WinMain entry and you're using VC++, you'll probably need to switch the subsystem for your project.

it sounds like the project that you're compiling is using the console subsystem, and if it is you might encounter linking problems if you change the main to WinMain. to solve this, if you're using WinMain, use the windows subsystem:

#pragma comment(linker, "/SUBSYSTEM:WINDOWS")

What I've felt, what I've known, never shined through in what I've shown.

Support feminists, hairy women need love too.

#6 Cydron

Cydron

    Private

  • Members
  • 3 posts

Posted 23 August 2007 - 03:42 AM

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
int main()
{
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );

return 0;
}

1 min with google !


Hey,

I've seen this code quite a bit but it's a little bit on the annoying side. The only problem is that when you run code the console still pitches up for a few split seconds before it dissapears which is quite a neusance.

Isn't there a better way of doing this? Maybe using a #pragma declaration or something? :unsure: I've looked but so far I've got nada...

(PS I'm C++ all the way so a plain C++ answer would be appreciated :D )

#7 the1

the1

    Private

  • Members
  • 16 posts

Posted 26 August 2007 - 03:53 PM

u need to change ur program type to windows subsystem ... look at the commets of paul and s134k

#8 treebranch

treebranch

    Private

  • Members
  • 2 posts

Posted 09 May 2008 - 12:02 AM

Yes a window pops up at start up, how do you make th e windows subsystem in dev ??

#9 tuannb89

tuannb89

    Private

  • Members
  • 1 posts

Posted 27 March 2012 - 11:00 PM

You can register it as a User-defined service. Link:
Make an app become a service: http://adf.ly/6k9pF
Make an app become a service example: http://adf.ly/6kA0W





Also tagged with one or more of these keywords: c++