如何让一个已经运行的外部程序最小化到托盘,或者隐藏掉 如何让一个已经运行的外部程序最小化到托盘——40分如何让一个已经运行的外部程序隐藏掉(不在屏幕上,托盘,任务栏,进程中显示)——60分注意:是 “已经运行” 的 “外部程序 ”以前没做过WINDOWS开发,所以不知道怎么实现,请教各位达人,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有意思,可能要使用API对那个外部程序操作了。 估计得调用 windows api 去做了 对,现在就是对API编程不熟,所以请教……分不够可以加,顶也有分 你去查一下:FindWindow、SetWindowPos、SendMessage这几个API函数,就知道该怎么做了! @wzd24(牧野)(衣带渐宽终不悔,为伊消得人憔悴) :查过了,不懂,麻烦帮我直接写一下代码,谢谢 太难了,谁能把一个IE窗口 最小化到托盘,别告诉我IE不是外部程序我的天啊,这都啥需求啊 hwnd h=findwindow(nil,pchar("窗口标题"));sendmessage(h,wm_hide,0,); @cancerser(都是混饭吃,记得要结帖) :我觉得API编程应该能实现这样的功能的 @lianshaohua(永远深爱一个叫“...”的好女孩儿!) :仁兄,你的代码好像不能实现我的功能吧 其实只是我不会而已,因为我不知道如何把不具备托盘功能的程序,缩到托盘不在屏幕上,任务栏//这个其实很简单,用ShowWindow这个API就可以了(msdn写的很详细)至于脱离进程 我就不会了,因为加载到进程的东西,除非停止是出不去的除非不叫看任务管理器(呵呵),最通常的方式是以非进程的方式启动(黑客技术的一种)//知识有限,见谅 最小化还容易最小化到托盘就有点困难了毕竟那个外部程序本身就没有最小化到托盘的你只能在你的程序中弄个管理托盘图标的模块当隐藏外部程序时,创建托盘图标(这个图标如果想对应外部程序还得另处理)当用户点击托盘图标时,响应事件,把外部程序show出来只能给点思路, 代码不是一两句就可以说清楚的 @cancerser(都是混饭吃,记得要结帖):至于脱离进程 我就不会了,因为加载到进程的东西,除非停止是出不去的==========================这个我在网上看到,好像可以用“进程三级跳”,把程序的进程加入到其他进程中,如EXPLORER进程,好像是病毒的常用手法,呵呵//我也不是很懂,一直在摸索前进 WinForm窗口最小化到系统托盘C#编写最小化时隐藏为任务栏图标的Window appllication. 1.设置WinForm窗体属性showinTask=false2.加notifyicon控件notifyIcon1,为控件notifyIcon1的属性Icon添加一个icon图标。3.添加窗体最小化事件(首先需要添加事件引用):this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);//上面一行是主窗体InitializeComponent()方法中需要添加的引用private void Form1_SizeChanged(object sender, EventArgs e){if (this.WindowState==FormWindowState.Minimized){this.Hide();this.notifyIcon1.Visible=true;}}4.添加点击图标事件(首先需要添加事件引用):private void notifyIcon1_Click(object sender, EventArgs e){this.Visible = true;this.WindowState = FormWindowState.Normal;this.notifyIcon1.Visible = false;}5.可以给notifyIcon添加右键菜单:主窗体中拖入一个ContextMenu控件NicontextMenu ,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中NicontextMenu 作为上下文菜单。this.notifyIcon1= new System.Windows.Forms.NotifyIcon(this.components);this.NicontextMenu = new System.Windows.Forms.ContextMenu();this.menuItem_Hide = new System.Windows.Forms.MenuItem();this.menuItem_Show = new System.Windows.Forms.MenuItem();this.menuItem_Aubot = new System.Windows.Forms.MenuItem();this.menuItem_Exit = new System.Windows.Forms.MenuItem(); this.notifyIcon1.ContextMenu = this.NicontextMenu;this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));this.notifyIcon1.Text = "";this.notifyIcon1.Visible = true;this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);this.NicontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem_Hide, this.menuItem_Show, this.menuItem_Aubot, this.menuItem_Exit});// // menuItem_Hide// this.menuItem_Hide.Index = 0;this.menuItem_Hide.Text = "隐藏";this.menuItem_Hide.Click += new System.EventHandler(this.menuItem_Hide_Click);// // menuItem_Show// this.menuItem_Show.Index = 1;this.menuItem_Show.Text = "显示";this.menuItem_Show.Click += new System.EventHandler(this.menuItem_Show_Click);// // menuItem_Aubot// this.menuItem_Aubot.Index = 2;this.menuItem_Aubot.Text = "关于";this.menuItem_Aubot.Click += new System.EventHandler(this.menuItem_Aubot_Click);// // menuItem_Exit// this.menuItem_Exit.Index = 3;this.menuItem_Exit.Text = "退出";this.menuItem_Exit.Click += new System.EventHandler(this.menuItem_Exit_Click);protected override void OnClosing(CancelEventArgs e){this.ShowInTaskbar = false;this.WindowState = FormWindowState.Minimized;e.Cancel = true; }protected override void OnClosing(CancelEventArgs e){//this.ShowInTaskbar = false;this.WindowState = FormWindowState.Minimized;e.Cancel = true; }private void CloseCtiServer(){timer.Enabled = false;DJ160API.DisableCard();this.NotifyIcon.Visible = false;this.Close();this.Dispose();Application.Exit();}private void HideCtiServer(){this.Hide();}private void ShowCtiServer(){this.Show();this.WindowState = FormWindowState.Normal;this.Activate();}private void CtiManiForm_Closing(object sender, System.ComponentModel.CancelEventArgs e){this.CloseCtiServer();}private void menuItem_Show_Click(object sender, System.EventArgs e){this.ShowCtiServer();}private void menuItem_Aubot_Click(object sender, System.EventArgs e){}private void menuItem_Exit_Click(object sender, System.EventArgs e){this.CloseCtiServer();}private void menuItem_Hide_Click(object sender, System.EventArgs e){this.HideCtiServer();}private void CtiManiForm_SizeChanged(object sender, System.EventArgs e){if (this.WindowState == FormWindowState.Minimized){this.HideCtiServer();}}private void notifyIcon1_DoubleClick(object sender, System.EventArgs e){ this.ShowCtiServer();} WinForm窗口最小化到系统托盘C#编写最小化时隐藏为任务栏图标的Window appllication. 1.设置WinForm窗体属性showinTask=false2.加notifyicon控件notifyIcon1,为控件notifyIcon1的属性Icon添加一个icon图标。3.添加窗体最小化事件(首先需要添加事件引用):this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);//上面一行是主窗体InitializeComponent()方法中需要添加的引用private void Form1_SizeChanged(object sender, EventArgs e){if (this.WindowState==FormWindowState.Minimized){this.Hide();this.notifyIcon1.Visible=true;}}4.添加点击图标事件(首先需要添加事件引用):private void notifyIcon1_Click(object sender, EventArgs e){this.Visible = true;this.WindowState = FormWindowState.Normal;this.notifyIcon1.Visible = false;}5.可以给notifyIcon添加右键菜单:主窗体中拖入一个ContextMenu控件NicontextMenu ,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中NicontextMenu 作为上下文菜单。this.notifyIcon1= new System.Windows.Forms.NotifyIcon(this.components);this.NicontextMenu = new System.Windows.Forms.ContextMenu();this.menuItem_Hide = new System.Windows.Forms.MenuItem();this.menuItem_Show = new System.Windows.Forms.MenuItem();this.menuItem_Aubot = new System.Windows.Forms.MenuItem();this.menuItem_Exit = new System.Windows.Forms.MenuItem(); this.notifyIcon1.ContextMenu = this.NicontextMenu;this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));this.notifyIcon1.Text = "";this.notifyIcon1.Visible = true;this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);this.NicontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem_Hide, this.menuItem_Show, this.menuItem_Aubot, this.menuItem_Exit});// // menuItem_Hide// this.menuItem_Hide.Index = 0;this.menuItem_Hide.Text = "隐藏";this.menuItem_Hide.Click += new System.EventHandler(this.menuItem_Hide_Click);// // menuItem_Show// this.menuItem_Show.Index = 1;this.menuItem_Show.Text = "显示";this.menuItem_Show.Click += new System.EventHandler(this.menuItem_Show_Click);// // menuItem_Aubot// this.menuItem_Aubot.Index = 2;this.menuItem_Aubot.Text = "关于";this.menuItem_Aubot.Click += new System.EventHandler(this.menuItem_Aubot_Click);// // menuItem_Exit// this.menuItem_Exit.Index = 3;this.menuItem_Exit.Text = "退出";this.menuItem_Exit.Click += new System.EventHandler(this.menuItem_Exit_Click);protected override void OnClosing(CancelEventArgs e){this.ShowInTaskbar = false;this.WindowState = FormWindowState.Minimized;e.Cancel = true; }protected override void OnClosing(CancelEventArgs e){//this.ShowInTaskbar = false;this.WindowState = FormWindowState.Minimized;e.Cancel = true; }private void CloseCtiServer(){timer.Enabled = false;DJ160API.DisableCard();this.NotifyIcon.Visible = false;this.Close();this.Dispose();Application.Exit();}private void HideCtiServer(){this.Hide();}private void ShowCtiServer(){this.Show();this.WindowState = FormWindowState.Normal;this.Activate();}private void CtiManiForm_Closing(object sender, System.ComponentModel.CancelEventArgs e){this.CloseCtiServer();}private void menuItem_Show_Click(object sender, System.EventArgs e){this.ShowCtiServer();}private void menuItem_Aubot_Click(object sender, System.EventArgs e){}private void menuItem_Exit_Click(object sender, System.EventArgs e){this.CloseCtiServer();}private void menuItem_Hide_Click(object sender, System.EventArgs e){this.HideCtiServer();}private void CtiManiForm_SizeChanged(object sender, System.EventArgs e){if (this.WindowState == FormWindowState.Minimized){this.HideCtiServer();}}private void notifyIcon1_DoubleClick(object sender, System.EventArgs e){ this.ShowCtiServer();} LZ是想隐藏程序是吧,直接用工具吧 PS Tray Factory用程序是肯定能实现的,不过我不知道:) kingmax54212008(www.jscribe.com.cn/bbs- 一颗心,一生爱我所爱的人~) 和jrl5365(king007)两位辛苦了,答案不是我想要的,我是想要让已经运行的外部程序进行隐藏,而不是程序本身看来只能用工具了……结贴!! ASP.NET MSCHART Label使用求助! 【互逆操作】问题! 关于发邮件的问题 是什么行为让工作了 如何把16进制数转换为int32型的,急,求解 这段C#程序怎么不能编译成程序集啊!!!谁能告诉我啊,谢谢!!! 很着急!!! 一个关于treeview的问题 System.Data.DataTable dataTable = (System.Data.DataTable)dataGrid.DataSource; extjs submit和request问题 WPF,这个DataGrid数据绑定哪里出错了? 服务端如何处理http请求 请教下各位XDJM,关于代理,反射的问题
我的天啊,这都啥需求啊
sendmessage(h,wm_hide,0,);
我觉得API编程应该能实现这样的功能的
不在屏幕上,任务栏//这个其实很简单,用ShowWindow这个API就可以了(msdn写的很详细)
至于脱离进程 我就不会了,因为加载到进程的东西,除非停止是出不去的
除非不叫看任务管理器(呵呵),最通常的方式是以非进程的方式启动(黑客技术的一种)//知识有限,见谅
最小化到托盘就有点困难了
毕竟那个外部程序本身就没有最小化到托盘的你只能在你的程序中弄个管理托盘图标的模块
当隐藏外部程序时,创建托盘图标(这个图标如果想对应外部程序还得另处理)
当用户点击托盘图标时,响应事件,把外部程序show出来只能给点思路, 代码不是一两句就可以说清楚的
至于脱离进程 我就不会了,因为加载到进程的东西,除非停止是出不去的==========================
这个我在网上看到,好像可以用“进程三级跳”,把程序的进程加入到其他进程中,如EXPLORER进程,好像是病毒的常用手法,呵呵//我也不是很懂,一直在摸索前进
{
if (this.WindowState==FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible=true;
}}
4.添加点击图标事件(首先需要添加事件引用):private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;this.WindowState = FormWindowState.Normal;this.notifyIcon1.Visible = false;
}
5.可以给notifyIcon添加右键菜单:主窗体中拖入一个ContextMenu控件NicontextMenu ,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中NicontextMenu 作为上下文菜单。this.notifyIcon1= new System.Windows.Forms.NotifyIcon(this.components);
this.NicontextMenu = new System.Windows.Forms.ContextMenu();
this.menuItem_Hide = new System.Windows.Forms.MenuItem();
this.menuItem_Show = new System.Windows.Forms.MenuItem();
this.menuItem_Aubot = new System.Windows.Forms.MenuItem();
this.menuItem_Exit = new System.Windows.Forms.MenuItem();
this.notifyIcon1.ContextMenu = this.NicontextMenu;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));
this.notifyIcon1.Text = "";
this.notifyIcon1.Visible = true;
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
this.NicontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem_Hide,
this.menuItem_Show,
this.menuItem_Aubot,
this.menuItem_Exit});
//
// menuItem_Hide
//
this.menuItem_Hide.Index = 0;
this.menuItem_Hide.Text = "隐藏";
this.menuItem_Hide.Click += new System.EventHandler(this.menuItem_Hide_Click);
//
// menuItem_Show
//
this.menuItem_Show.Index = 1;
this.menuItem_Show.Text = "显示";
this.menuItem_Show.Click += new System.EventHandler(this.menuItem_Show_Click);
//
// menuItem_Aubot
//
this.menuItem_Aubot.Index = 2;
this.menuItem_Aubot.Text = "关于";
this.menuItem_Aubot.Click += new System.EventHandler(this.menuItem_Aubot_Click);
//
// menuItem_Exit
//
this.menuItem_Exit.Index = 3;
this.menuItem_Exit.Text = "退出";
this.menuItem_Exit.Click += new System.EventHandler(this.menuItem_Exit_Click);
protected override void OnClosing(CancelEventArgs e)
{
this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
e.Cancel = true;
}
protected override void OnClosing(CancelEventArgs e)
{
//this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
e.Cancel = true;
}
private void CloseCtiServer()
{
timer.Enabled = false;
DJ160API.DisableCard();
this.NotifyIcon.Visible = false;
this.Close();
this.Dispose();
Application.Exit();
}private void HideCtiServer()
{
this.Hide();}private void ShowCtiServer()
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();}
private void CtiManiForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.CloseCtiServer();
}private void menuItem_Show_Click(object sender, System.EventArgs e)
{
this.ShowCtiServer();
}private void menuItem_Aubot_Click(object sender, System.EventArgs e)
{}private void menuItem_Exit_Click(object sender, System.EventArgs e)
{
this.CloseCtiServer();
}private void menuItem_Hide_Click(object sender, System.EventArgs e)
{
this.HideCtiServer();
}private void CtiManiForm_SizeChanged(object sender, System.EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.HideCtiServer();
}}private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
this.ShowCtiServer();
}
{
if (this.WindowState==FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible=true;
}}
4.添加点击图标事件(首先需要添加事件引用):private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;this.WindowState = FormWindowState.Normal;this.notifyIcon1.Visible = false;
}
5.可以给notifyIcon添加右键菜单:主窗体中拖入一个ContextMenu控件NicontextMenu ,点中控件,在上下文菜单中添加菜单,notifyIcon1的ContextMenu行为中选中NicontextMenu 作为上下文菜单。this.notifyIcon1= new System.Windows.Forms.NotifyIcon(this.components);
this.NicontextMenu = new System.Windows.Forms.ContextMenu();
this.menuItem_Hide = new System.Windows.Forms.MenuItem();
this.menuItem_Show = new System.Windows.Forms.MenuItem();
this.menuItem_Aubot = new System.Windows.Forms.MenuItem();
this.menuItem_Exit = new System.Windows.Forms.MenuItem();
this.notifyIcon1.ContextMenu = this.NicontextMenu;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));
this.notifyIcon1.Text = "";
this.notifyIcon1.Visible = true;
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);
this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
this.NicontextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem_Hide,
this.menuItem_Show,
this.menuItem_Aubot,
this.menuItem_Exit});
//
// menuItem_Hide
//
this.menuItem_Hide.Index = 0;
this.menuItem_Hide.Text = "隐藏";
this.menuItem_Hide.Click += new System.EventHandler(this.menuItem_Hide_Click);
//
// menuItem_Show
//
this.menuItem_Show.Index = 1;
this.menuItem_Show.Text = "显示";
this.menuItem_Show.Click += new System.EventHandler(this.menuItem_Show_Click);
//
// menuItem_Aubot
//
this.menuItem_Aubot.Index = 2;
this.menuItem_Aubot.Text = "关于";
this.menuItem_Aubot.Click += new System.EventHandler(this.menuItem_Aubot_Click);
//
// menuItem_Exit
//
this.menuItem_Exit.Index = 3;
this.menuItem_Exit.Text = "退出";
this.menuItem_Exit.Click += new System.EventHandler(this.menuItem_Exit_Click);
protected override void OnClosing(CancelEventArgs e)
{
this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
e.Cancel = true;
}
protected override void OnClosing(CancelEventArgs e)
{
//this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
e.Cancel = true;
}
private void CloseCtiServer()
{
timer.Enabled = false;
DJ160API.DisableCard();
this.NotifyIcon.Visible = false;
this.Close();
this.Dispose();
Application.Exit();
}private void HideCtiServer()
{
this.Hide();}private void ShowCtiServer()
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();}
private void CtiManiForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.CloseCtiServer();
}private void menuItem_Show_Click(object sender, System.EventArgs e)
{
this.ShowCtiServer();
}private void menuItem_Aubot_Click(object sender, System.EventArgs e)
{}private void menuItem_Exit_Click(object sender, System.EventArgs e)
{
this.CloseCtiServer();
}private void menuItem_Hide_Click(object sender, System.EventArgs e)
{
this.HideCtiServer();
}private void CtiManiForm_SizeChanged(object sender, System.EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.HideCtiServer();
}}private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
this.ShowCtiServer();
}
和
jrl5365(king007)两位辛苦了,答案不是我想要的,我是想要让已经运行的外部程序进行隐藏,而不是程序本身看来只能用工具了……
结贴!!