调用外边exe,判断:
如果未启动则启动,这个知道
如果已启动则将exe窗体变成激活窗体,显示在最前面,如何实现?
Process[] myprocess = Process.GetProcessesByName("InfoColl");
if (myprocess.Length > 0)
{
// myprocess[0].CloseMainWindow();//这样处理不好,想改成激活最大化,如何实现????
//myprocess[0].Close(); }
else
{
Process.Start("InfoColl.exe");
}
如果未启动则启动,这个知道
如果已启动则将exe窗体变成激活窗体,显示在最前面,如何实现?
Process[] myprocess = Process.GetProcessesByName("InfoColl");
if (myprocess.Length > 0)
{
// myprocess[0].CloseMainWindow();//这样处理不好,想改成激活最大化,如何实现????
//myprocess[0].Close(); }
else
{
Process.Start("InfoColl.exe");
}
解决方案 »
- 请问C#调用C的DLL,如何获取通过Marshal.StructureToPtr得到的结构体指针中的元素?
- 这个词法是什么意思.. 各位有没有可否跟一个例子...
- 一个聪明+不聪明的想法~!!
- 关于c#中线程关闭后资源回收的问题^!^如何解决
- 那位达人能说说虚函数的new和override方法的区别
- MSN Messenger 6.2中个性化标签的添加、修改和编辑???
- 关于构造函数和静态方法,谁能帮我解释一下??
- 请问怎样判断某用户离线?
- 如何解决C#中类库引用无效?
- c#和三菱plc(Q系列)通过tcp通讯问题
- C#中SQL语句换行
- 没锁定的多线程运算,结果达不到预期的为什么了?说下和同步运算的区别
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);
public const uint WM_SYSCOMMAND = 0x0112;
public const uint SC_MAXIMIZE = 0xF030;[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);[DllImport("user32.dll")]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);if (myprocess.Length > 0)
{
IntPtr handle = myprocess[0].MainWindowHandle;
SendMessage(handle, WM_SYSCOMMAND, new IntPtr(SC_MAXIMIZE), IntPtr.Zero); // 最大化
SwitchToThisWindow(handle, true); // 激活
}