获得窗体的句柄,然后用sendmessage对其进行操作

解决方案 »

  1.   

    const int SW_HIDE = 0;
    const int SW_SHOW = 5;/// <summary>
    /// 查找窗口
    /// </summary>
    [DllImport("user32.dll")]
    internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);[DllImport("user32.dll")]
    internal static extern int ShowWindow(IntPtr hWin, int nCmdShow);
    //这里第一个参数必须是IntPtr型的private void button1_Click(object sender, System.EventArgs e) {
    Process myProcess = new Process();            
    try {
    myProcess.StartInfo.FileName = @"C:\SlotApp.exe";
    myProcess.StartInfo.CreateNoWindow = true;
    myProcess.Start();
    ShowWindow(FindWindow(null, myProcess.MainWindowTitle), SW_HIDE);
    }catch{
    }
    }
      

  2.   

    如果要显示,ShowWindow(FindWindow(null, myProcess.MainWindowTitle), SW_SHOW);
      

  3.   

    楼主既然你不需要Win的窗体而只要运行程序建议你使用Win服务!也就是NT服务了!
    不是更好吗?何必那么麻烦要把窗体隐藏起来。呵呵!!!
      

  4.   

    简单地将Form的ShowInTaskbar设为false,WindowState设为Minimized就行
      

  5.   

    请用adailee(不谈恋爱的铅笔)的方法。
      

  6.   

    Process myProcess = new Process();            
    try {
      myProcess.StartInfo.FileName = @"C:\SlotApp.exe";
      myProcess.StartInfo.WindowStyle  = ProcessWindowStyle.Hidden;
      myProcess.Start();
    }catch{
    }
    这样更简洁。别忘记应用using System.Diagnostics;