.net – 在Windows任务栏中对单独的进程进行分组
发布时间:2020-12-14 05:27:38 所属栏目:Windows 来源:网络整理
导读:我有许多逻辑相关的独立进程(但所有进程都是单独启动的 – 没有共同的’父’进程). 是否可以使它们在Windows任务栏中显示为一个组? 工作样本 这是一些灵感来自雷米答案的工作代码 using System;using System.Runtime.InteropServices;using System.Security
我有许多逻辑相关的独立进程(但所有进程都是单独启动的 – 没有共同的’父’进程).
是否可以使它们在Windows任务栏中显示为一个组? 工作样本 这是一些灵感来自雷米答案的工作代码 using System; using System.Runtime.InteropServices; using System.Security; namespace ConsoleApplication1 { [SuppressUnmanagedCodeSecurity] internal static class SafeNativeMethods { [DllImport("shell32.dll")] public static extern int SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID); [DllImport("kernel32.dll")] public static extern bool AllocConsole(); [DllImport("kernel32.dll")] public static extern bool FreeConsole(); } internal class Program { public static int SetApplicationUserModelId(string appId) { // check for Windows 7 Version version = Environment.OSVersion.Version; if ((version.Major > 6) || (version.Major == 6 && version.Minor >= 1)) return SafeNativeMethods.SetCurrentProcessExplicitAppUserModelID(appId); return -1; } [STAThread] public static void Main(string[] args) { int result = SetApplicationUserModelId("Gardiner.Sample1"); SafeNativeMethods.AllocConsole(); // Now we have a console,we can write to it Console.Title = "Sample 1"; Console.WriteLine("Sample 1 {0}",result); Console.ReadLine(); SafeNativeMethods.FreeConsole(); } } } 要使其工作,必须将可执行文件设置为将“输出类型”设置为“Windows应用程序”,并将“启动对象”配置为“ConsoleApplication1.Program”(对于上面的代码示例). 解决方法
是的,但仅限于Windows 7及更高版本.如果多个进程和窗口具有分配给它们的相同
Application User Model ID,则它们在任务栏上组合在一起.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- webpack’不是内部命令,也不是可运行程序或批处理文件(wi
- Win10 下 hadoop3.0.0 单机部署
- wix – 如何运行具有提升权限的自定义可执行文件?
- 如何从我的开发环境中的Windows 7 x64上的C#连接到Oracle数
- 读取NTFS的USN(获取文件的历史操作记录,即使这个文件已被
- windows-server-2008-r2 – 从ESXi 4.1中的模板部署Windows
- windows-7 – 将漫游配置文件移动到DFS
- windows – 在给定变量中转义百分号
- windows远程桌面函数无效和RDS报错的典型案例分析
- active-directory – Windows 10,RSAT工具缺少功能
推荐文章
站长推荐
热点阅读