using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Reflection; using System.Runtime.InteropServices; namespace WindowsApplication16 { public partial class Form1 : Form { public const int SW_HIDE = 0; public const int SW_NORMAL = 1; public const int SW_SHOWMINIMIZED = 2; public const int SW_SHOWMAXIMIZED = 3; [DllImport("User32.dll")] public static extern void SetForegroundWindow(IntPtr hwnd); [DllImport("User32.dll")] public static extern IntPtr GetForegroundWindow(); [DllImport("User32.dll")] public static extern int GetWindowThreadProcessId(IntPtr hwnd, IntPtr pProcId); [DllImport("User32.dll")] public static extern bool AttachThreadInput(int idAttach, int idAttachTo, int fAttach); [DllImport("User32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Process[] plist = Process.GetProcesses(); int cid = Process.GetCurrentProcess().Id; for (int i = 0; i < plist.Length; i++) if (cid != plist[i].Id) { string s = plist[i].ProcessName; if (s == @"Uedit32") { MessageBox.Show(s);
Process[] plist = Process.GetProcesses(); int cid = Process.GetCurrentProcess().Id; for (int i = 0; i < plist.Length; i++) if (cid != plist[i].Id) { string s = plist[i].ProcessName; if (s == @"Uedit32") { MessageBox.Show(s);
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
namespace WindowsApplication16
{
public partial class Form1 : Form
{
public const int SW_HIDE = 0;
public const int SW_NORMAL = 1;
public const int SW_SHOWMINIMIZED = 2;
public const int SW_SHOWMAXIMIZED = 3; [DllImport("User32.dll")]
public static extern void SetForegroundWindow(IntPtr hwnd); [DllImport("User32.dll")]
public static extern IntPtr GetForegroundWindow(); [DllImport("User32.dll")]
public static extern int GetWindowThreadProcessId(IntPtr hwnd, IntPtr pProcId); [DllImport("User32.dll")]
public static extern bool AttachThreadInput(int idAttach, int idAttachTo, int fAttach); [DllImport("User32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ Process[] plist = Process.GetProcesses();
int cid = Process.GetCurrentProcess().Id; for (int i = 0; i < plist.Length; i++)
if (cid != plist[i].Id)
{
string s = plist[i].ProcessName;
if (s == @"Uedit32")
{
MessageBox.Show(s);
ShowWindowAsync(plist[i].MainWindowHandle, SW_SHOWMAXIMIZED);
SetForegroundWindow(plist[i].MainWindowHandle); break;
} }
}
}
}
int cid = Process.GetCurrentProcess().Id; for (int i = 0; i < plist.Length; i++)
if (cid != plist[i].Id)
{
string s = plist[i].ProcessName;
if (s == @"Uedit32")
{
MessageBox.Show(s);
ShowWindowAsync(plist[i].MainWindowHandle, SW_SHOWMAXIMIZED);
SetForegroundWindow(plist[i].MainWindowHandle); break;
} }以上部分如果放在Main函数里应该更好一些吧
否则,他还是会生成一个画面。
请指教。