C# C# 콘솔 프로젝트에서 창 안보이게 만들기. (Making the window show & hide in the C# cons…
페이지 정보
본문
C# 프로젝트에서 CMD를 호출할 때는 창을 안보이게 처리할 수 있는데요. 자체 콘솔 프로젝트인 경우 이런 속성(Property, 프로퍼티)이 없습니다. 그래서 윈도우 API를 이용해서 창을 숨겨야 하는데요. 자세한 코드는 아래 내용을 참고하세요.
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ConsoleTest
{
class Program
{
#region Windows API
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_HIDE = 0;
const int SW_SHOW = 1;
#endregion
static void Main(string[] args)
{
// 콘솔창이 표시되지 않도록 합니다.
ShowWindow(GetConsoleWindow(), SW_HIDE);
your code ...
개발자에게 후원하기
추천, 구독, 홍보 꼭~ 부탁드립니다.
여러분의 후원이 빠른 귀농을 가능하게 해줍니다~ 답답한 도시를 벗어나 귀농하고 싶은 개발자~
감사합니다~
추천1 비추천0
- 이전글Microsoft SQL Server 설치 하기. 21.05.23
- 다음글프로세스의 DPI 인식 방법. 21.05.21
댓글목록
등록된 댓글이 없습니다.