티스토리 뷰
Process 클래스를 이용해서 원하는 Window(Process)의 핸들값을 얻는 샘플 코드이다.
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace ControlHandle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.Text = String.Empty;
Process[] processes = Process.GetProcessesByName("notepad");
foreach (Process proc in processes)
{
IntPtr hWnd = proc.MainWindowHandle;
this.textBox1.Text += hWnd.ToString() + Environment.NewLine;
}
}
}
}
아래는 실행 결과 화면이다.
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace ControlHandle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.Text = String.Empty;
Process[] processes = Process.GetProcessesByName("notepad");
foreach (Process proc in processes)
{
IntPtr hWnd = proc.MainWindowHandle;
this.textBox1.Text += hWnd.ToString() + Environment.NewLine;
}
}
}
}
아래는 실행 결과 화면이다.
'Code > C#' 카테고리의 다른 글
| [C#] const vs readonly (0) | 2008.02.11 |
|---|---|
| PInvoke SetForegroundWindow Sample Code (0) | 2008.01.14 |
| GenericDictionaryXmlSerializer 클래스 2 사용 예제 (0) | 2007.12.16 |
| Generic Dictionary Xml Serialization C# Example 2 (0) | 2007.12.16 |
| Generic Dictionary Xml Serialization C# Example 1 (0) | 2007.12.16 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Sample Code
- DotNetMagic
- windows
- Rollback Rx
- registry
- 스크린캡쳐
- READYSTATE_COMPLETE
- iText
- AxWebBrowser
- autohotkey
- WinAutomation
- .net framework
- download.com
- Automation
- Regular Expressions
- iTextSharp
- Microsoft
- c#
- Service pack
- tagREADYSTATE
- jre
- Phalanger
- AdSense숨기기
- 애드센스감추기
- java
- 애드센스숨기기
- AdSense감추기
- ScreenHunter
- 유틸리티
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함