wpf 打开外部程序并在需要时激活
2014-12-21 11:56
295 查看
打开外部程序使用Process
激活窗体,通过SetForegroundWindow函数传递Process获取的句柄激活
激活窗体,通过SetForegroundWindow函数传递Process获取的句柄激活
_external = new Process();
[DllImport("User32.dll", EntryPoint = "SetForegroundWindow")] public static extern int SetForegroundWindow(IntPtr hWnd); public void Run(string file, string args) { bool _bExisted = true; try { if (_external.HasExited == false) { _bExisted = false; SetForegroundWindow(_external.MainWindowHandle); return; } } catch (Exception e) { Global.MainLogging.LogError("ExternalProcess.Run:param1:" + file + ",param2:" + args + "," + e.ToString()); } finally { if (_bExisted) RunExternal(file, args); } }
相关文章推荐
- Qt打开外部程序和文件夹需要注意的细节(Qt调用VC写的动态库,VC需要用C的方式输出函数,否则MinGW32编译过程会报错)
- Qt打开外部程序和文件夹需要注意的细节(注意QProcess的空格问题,以及打开本地文件时,需要QUrl::fromLocalFile才可以)
- WinAPI: ShellExecute - 打开外部程序或文件
- delphi调用外部程序打开文件
- C# 程序只能运行一次(多次运行只能打开同一个程序) 并激活第一个实例,使其获得焦点,并在最前端显示.
- SQL数据库隐藏服务器后需要在连接字符串增加端口号,(provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)]
- Qt编程调用外部程序打开文件
- 打开并激活已存在程序窗口
- WinAPI: ShellExecute - 打开外部程序或文件
- WinAPI: ShellExecute - 打开外部程序或文件
- FLASH如何打开外部exe程序
- c/c++中运行外部程序或打开文件(转)
- Delphi使用系统默认程序打开外部文件
- C# 窗体边角圆弧处理及在C#中调用外部程序(执行批处理,打开窗口等)
- c# 程序只能运行一次(多次运行只能打开同一个程序) 并激活第一个实例,使其获得焦点,并在最前端显示.
- CSharp调用外部程序打开指定文件
- WinAPI: ShellExecute - 打开外部程序或文件
- VC程序只运行一个实例,并在打开多个时激活原窗口
- 如何在自己的系统中打开并关闭外部程序
- C# 打开外部程序或文件