Hide Console application window

Source: Internet
Author: User

Title, how can I hide the console black window when I create a new console application on Windows.

The first method:

:: Setconsoletitle (_t ("test_exe")); HWND hwnd=::findwindow (_t (""), _t ("test_exe"));:: ShowWindow (HWND,SW _hide);

No, try, don't know why the failure ....

Window handle caught, just don't understand why not hide ... ⊙﹏⊙ b Khan

The two methods catch the same handle, the same ShowWindow () function, one can, a not ... ⊙﹏⊙ b Khan, good pit ....

The second type:

Get the class name of the cmd window with Spy + +:

Get the class name of the console window: Consolewindowclass

Ok.

HWND hwnd;hwnd=::findwindow (_t ("consolewindowclass"), NULL);:: ShowWindow (hwnd,sw_hide);

You can hide the console window by calling the FindWindow () function OK from the window class name.

The third type:

Many of these are on the Internet:

#pragma COMMENT (linker, "/subsystem:\" windows\ "/entry:\" Wmaincrtstartup\ ") sets the linker configuration for vs.

Modify the default console property for Windows by setting the link subsystem, and make the main entry address for the program: wmainCRTStartup

(The Unicode character set is wmainCRTStartup, the multibyte character group is mainCRTStartup), and this way you can also achieve

Hides the effect of the console window.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.