问题:我有一个可执行文件,运行它打开一个窗体,我可不可以写一个C#程序,运行的时候,同时运行那个可执行文件,但是将其窗体隐藏! 获得窗体的句柄,然后用sendmessage对其进行操作 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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{ }} 如果要显示,ShowWindow(FindWindow(null, myProcess.MainWindowTitle), SW_SHOW); 楼主既然你不需要Win的窗体而只要运行程序建议你使用Win服务!也就是NT服务了!不是更好吗?何必那么麻烦要把窗体隐藏起来。呵呵!!! 简单地将Form的ShowInTaskbar设为false,WindowState设为Minimized就行 请用adailee(不谈恋爱的铅笔)的方法。 Process myProcess = new Process(); try { myProcess.StartInfo.FileName = @"C:\SlotApp.exe"; myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; myProcess.Start();}catch{} 这样更简洁。别忘记应用using System.Diagnostics; 未知实体类对象的类型赋予 线程一句代码的疑问 如何给事件处理程序传递参数 vs2003/vs2005用了一段时间了,谈谈c#与vb.net的区别? 求一winform中文本框限定只能输数字 的实现方案 .. 请教~~~~~如何得知虚拟路径对应的实际路径? 关于字体重新设置格式的问题 很简单的问题,(C#)session存储ID要怎么看? 急~~ 懂b\s编程的进来帮帮忙啊 在线等 求助(急,需要源代码) ReadFile() API函数导入的原型应该怎么写? 我的在下面,但不行,:( 安装vs为什么会这样!!!!
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{
}
}
不是更好吗?何必那么麻烦要把窗体隐藏起来。呵呵!!!
try {
myProcess.StartInfo.FileName = @"C:\SlotApp.exe";
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.Start();
}catch{
}
这样更简洁。别忘记应用using System.Diagnostics;