| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- sensor
- subpixel
- aduino
- Encapusulation
- atmega328
- Pointer
- UNO
- flutter
- public
- Contour
- file access
- edge
- digitalRead
- Class
- Unity
- Android
- APP
- Read
- Binary
- mfc
- Filtering
- stream
- memory
- Gaussian
- SERIAL
- c++
- parameter
- compare
- Gradient
- wpf
- Today
- Total
폴크(FOLC)
C# 테크닉 - 프로세스 검색 본문
# 윈도우에서 현재 실행되고 있는 프로그램을 찾아보고 핸들을 이용해서 상태를 변경할 수 있다.
> FindWindow : 윈도우 핸들을 찾는다.
> ShowWindowAsync : 윈도우를 활성화 시킨다.
> SetForegroundWindow : 윈도우를 최상위로 이동 시킨다.
# 소스 코드
using System;
using System.Runtime.InteropServices;
class FindProcess
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
private const int SW_SHOWNORMAL = 1;
private const int SW_SHOWMINIMIZED = 2;
private const int SW_SHOWMAXIMIZED = 3;
void ActiveProcess(String proc_name)
{
IntPtr hWnd = FindWindow(null, proc_name);
if (hWnd.Equals(IntPtr.Zero) == false)
{
ShowWindowAsync(hWnd, SW_SHOWNORMAL);
SetForegroundWindow(hWnd);
}
}
}
'C#, WF, WPF(.NET) > C#, WF, WPF(.NET) 테크닉' 카테고리의 다른 글
| WPF 테크닉 - LiveChart 관련 site (0) | 2022.03.05 |
|---|---|
| WPF 테크닉 - Timer 운영 (0) | 2022.03.04 |
| C# 테크닉 - 스크린 캡쳐 (Bitmap) (0) | 2021.12.10 |
| C# 테크닉 - 시리얼 통신 ( RS232 ) (0) | 2021.12.10 |
| C# 테크닉 - 로그 기록하기 ( NLOG ) (0) | 2021.12.09 |