隐藏终端程序窗口

#include <iostream>
using namespace std;

// I'm using Vista ATM (it's evil), but GCC comes assuming the worst.
// If you haven't patched your compiler to agree with the actual version
// of the Windows OS, then you will need to make sure you do it like this.
//
#if       _WIN32_WINNT < 0x0500
  #undef  _WIN32_WINNT
  #define _WIN32_WINNT   0x0500
#endif
#include <windows.h>

// Here's some fun timer stuff for the user.
// (Notice how he won't see it work when the
//  console is hidden, but it will still work.)
void timeout()
  {
  for (int cntr = 3; cntr > 0; cntr--)
    {
    cout << "\r" << cntr << flush;
    Sleep( 1000 );
    }
  cout << "\r" << flush;
  }

// Demonstrate some fun stuff.
// Notice how hiding the console window causes it to disappear from
// the Windows task bar. If you only want to make it minimize, use
// SW_MINIMIZE instead of SW_HIDE.
//
int main()
  {
  cout << "Preparing to hide the console window\n";
  timeout();
  ShowWindow( GetConsoleWindow(), SW_HIDE );

  cout << "Preparing to show the console window\n";
  timeout();
  ShowWindow( GetConsoleWindow(), SW_RESTORE );

  cout << "All done!\n";
  return 0;
  }

copy from: http://www.cplusplus.com/forum/beginner/12001/

转载于:https://www.cnblogs.com/albertofwb/p/6184541.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值