C# 메모장 열기 및 내용 작성

3831 단어 공책
C# 메모장을 열고 다음 내용 코드를 입력합니다.

 
   
using System.Runtime.InteropServices;
using System.Diagnostics;

[DllImport(
" User32.DLL " )]
public static extern int SendMessage(IntPtr hWnd,
uint Msg, int wParam, string lParam);
[DllImport(
" User32.DLL " )]
public static extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter,
string lpszClass, string lpszWindow);
public const uint WM_SETTEXT = 0x000C ;
private void button1_Click( object sender, EventArgs e)
{
Process vProcess
= Process.Start( " notepad.exe " );
while (vProcess.MainWindowHandle == IntPtr.Zero) vProcess.Refresh();
IntPtr vHandle
= FindWindowEx(vProcess.MainWindowHandle,
IntPtr.Zero,
" Edit " , null );
SendMessage(vHandle, WM_SETTEXT,
0 , " Zswang " );
}

좋은 웹페이지 즐겨찾기