日期:2014-05-17  浏览次数:21080 次

启动第三方程序并隐藏显示。
windows xp中,怎样编程实现,启动windows计算器程序calculator.exe并隐藏显示(要求任务栏中也不出现,显示在通知区)。求C#完整代码,最好调试通过能实现上述功能。我试过网上很多代码都不行。

------解决方案--------------------
process貌似有个参数:是否显示窗口。如果这个程序没有通知栏的,可以在自己的调用程序里面帮它加一个的。
------解决方案--------------------
在windows上面后台运行可以使用start 命令 并且指定/b 选项, linux系统需要在命令后面加上& 符号即可。

后台运行 iperf.exe 网络测试程序,并且把输出保存到 c:\iperf_multicast_server_logfile.txt 
start /b iperf.exe -s -u -l 1k -B 224.0.100.2 -w 1G > c:\iperf_multicast_server_logfile.txt
------解决方案--------------------
1,声明PAI函数
[DllImport("kernel32.dll", EntryPoint = "WinExec")]
public static extern int WinExec(string lpCmdLine, int nCmdShow);

[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);

2,在合适的地方调用上面声明的PAI函数,测试记事本可以隐藏,但计算器只能显示在任务栏最小化。
WinExec("calc.exe", 0);
IntPtr hand = FindWindow(null, "Calculator");//Calcutator 是 窗体的名字,我的系统是英文版所以是Calculator,如果是中文的,则是“计算器”了。
ShowWindow(hand, 2);