c#.net

c#.netcf winapi

우유빛 2009. 9. 14. 00:20


[DllImport("user32.dll", EntryPoint = "SetWindowText", CharSet = CharSet.Ansi)]
public static extern bool SetWindowText(IntPtr hWnd, String strNewWindowName);

[DllImport("coredll.dll")]
public static extern IntPtr FindWindow(string className, string windowName);

[DllImport("coredll.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, uint wParam, uint lParam);

[DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Ansi)]
public static extern bool GetWindowText(IntPtr hWnd, [OutAttribute()] StringBuilder strNewWindowName,
   
Int32 maxCharCount);



SetWindowText(this.Handle, "Hello World");
SetWindowText(FindWindow(null, "Solitaire"), "Care Bear");
StringBuilder sbWinText = new StringBuilder(256);
GetWindowText(FindWindow("Solitaire", null), sbWinText, 256);
MessageBox.Show(sbWinText.ToString())