日期:2014-05-19  浏览次数:21122 次

c# 调用外部程序 不在任务栏中出现 在屏幕上显示的问题
一个C#   WIN程序,我想在程序中调用一个外部程序,要求程序显示在屏幕上而不显示在任务栏中,在这儿找了很久,也看了不少别人的贴子,但一直都没有成功.

ProcessWindowStyle.Hidden;//不起作用

还有可不可以在程序中嵌入别的可执行文件?   我是新手,先谢谢了!

------解决方案--------------------
楼主变通一下思路,可控性更加灵活,而且实现正规。
思路如下:
假设你的C# WIN程序为a.exe,
而外部程序为b.exe
在b.exe的代码的Main函数的中处理如下:
using System;
using System.Windows.Forms;

namespace Zhzuo.VS2005Test
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form mainForm = new MainForm();
if (args.Length > 0)
{
string t = args[0].ToLower();
switch(t)
{
case "-notaskbar ":
mainForm.ShowInTaskbar = false;
break;
case "-taskbar ":
mainForm.ShowInTaskbar = true;
break;
default:
mainForm.ShowInTaskbar = true;
break;
}
mainForm.Text = args[0]; //show args
}
Application.Run(mainForm);

}
}
}

假设你的a.exe中调用b.exe的代码如下:
System.Diagnostics.Process.Start(@ "C:\b.exe ", "-notaskbar ");//no show taskbar

如果需要显示:
System.Diagnostics.Process.Start(@ "C:\b.exe ", "-taskbar ");//no show taskbar



------解决方案--------------------
SetWindowLong ( hwnd , GWL_EXSTYLE , WS_EX_TOOLWINDOW );
楼主自己转成P/Invoke的调用吧