■ 최소화된 UWP 앱을 일반 상태로 표시하는 방법을 보여준다.
▶ Program.cs
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
using System; using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; namespace TestProject { /// <summary> /// 프로그램 /// </summary> class Program { //////////////////////////////////////////////////////////////////////////////////////////////////// Import ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private #region 윈도우 찾기 - FindWindow(className, windowName) /// <summary> /// 윈도우 찾기 /// </summary> /// <param name="className">클래스명</param> /// <param name="windowName">윈도우명</param> /// <returns>윈도우 핸들</returns> [DllImport("user32", SetLastError = true)] private static extern IntPtr FindWindow(string className, string windowName); #endregion #region 윈도우 표시하기 - ShowWindow(windowHandle, command) /// <summary> /// 윈도우 표시하기 /// </summary> /// <param name="windowHandle">윈도우 핸들</param> /// <param name="command">명령</param> /// <returns>처리 결과</returns> [DllImport("user32")] private static extern bool ShowWindow(IntPtr windowHandle, int command); #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// SW_RESTORE /// </summary> private const int SW_RESTORE = 9; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private #region 프로그램 시작하기 - Main() /// <summary> /// 프로그램 시작하기 /// </summary> private static void Main() { Process process = Process.GetProcessesByName("Calculator").FirstOrDefault(); if(process != null) { IntPtr mainWindowHandle = process.MainWindowHandle; if(mainWindowHandle != IntPtr.Zero) { IntPtr windowHandle = FindWindow("ApplicationFrameWindow", process.MainWindowTitle); if(windowHandle != IntPtr.Zero) { ShowWindow(windowHandle, SW_RESTORE); } } } } #endregion } } |
※ 프로그램 실행하기 전, 계산기 앱을 실행하고 최소화 상태로 만든다.