티스토리 뷰
C#에서 콘솔 응용 프로그램을 숨기는 방법
using System;
using System.Runtime.InteropServices;
using System.Threading;
namespace hideconsole
{
class Program
{
[DllImport("Kernel32.dll")]
private static extern IntPtr GetConsoleWindow();
[DllImport("User32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int cmdShow);
static void Main(string[] args)
{
Console.WriteLine("아무키나 눌러주세요!!");
Console.ReadKey();
IntPtr hWnd = GetConsoleWindow();
if(hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 0); // 숨기기
Thread.Sleep(5000); // 5초
ShowWindow(hWnd, 1); // 보이기
}
Console.ReadKey();
}
}
}
'프로그래밍 > C#' 카테고리의 다른 글
C# 실시간으로 숫자 카운트하기 (0) | 2021.11.22 |
---|---|
백그라운드워커 (BackgroundWorker) (0) | 2021.09.27 |
C# 윈폼 숨기는 방법 코드 (0) | 2021.09.24 |
C# 텍스트 읽어주기 소스코드 (0) | 2021.09.24 |
c# Split 기능을 이용해 글자 정렬하기 (0) | 2021.03.29 |
댓글