根据标题获取窗口句柄

using System; 
  using System.Runtime.InteropServices; 
  namespace tstfindwindow 
  { 
  ///  
  /// Class1 的摘要说明。 
  ///  
  class Class1 
  { 
  [DllImport( "User32.dll ")] 
  public static extern System. IntPtr FindWindowEx(System. IntPtr parent, System. IntPtr childe, string strclass, string strname); 
  ///  
  /// 应用程序的主入口点。 
  ///  
  [STAThread] 
  static void Main(string[] args) 
  { 
  // 
  //TODO: 在此处添加代码以启动应用程序 
  // 
  IntPtr p=FindWindowEx(System.IntPtr.Zero,System.IntPtr.Zero,null,"窗口标题"); 
  } 
  }

发送消息控制最大、最小

[DllImport("user32.dll", EntryPoint = "PostMessage")]
public static extern int PostMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x112;
public const int SC_MINIMIZE = 0xF020;
public const int SC_MAXIMIZE = 0xF030;
private void button1_Click(object sender, EventArgs e)
{
    PostMessage(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
}

 

相关文章:

  • 2022-12-23
  • 2021-06-23
  • 2022-01-08
  • 2022-02-10
  • 2022-01-11
  • 2021-05-15
猜你喜欢
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-01-12
  • 2021-09-23
相关资源
相似解决方案