티스토리 뷰

 

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();
        }
    }
}

 

https://youtu.be/xVkKiWEQURI

 

- YouTube

 

www.youtube.com

 

댓글
최근에 달린 댓글
글 보관함
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Total
Today
Yesterday
    뽀로로친구에디
    최근에 올라온 글