[DllImport("user32.dll", EntryPoint="FindWindow")]
public static extern int FindWindow (
string lpClassName,
string lpWindowName
);[DllImport("user32.dll", EntryPoint="SetForegroundWindow")]
public static extern int SetForegroundWindow (
int hwnd
);
void btn_click(object sender, EventArgs e)
{
    int hwnd = FindWindow(null, "我的电脑");
    SetForegroundWindow(hwnd);
}

解决方案 »

  1.   

    先用FindWindow找到进程,然后设置该进程到最前端,我去找找我以前的代码,贴上来
      

  2.   

    补充一下,呵呵:
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern IntPtr FindWindow(string strclassName, string strWindowName);[System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern bool OpenIcon(IntPtr hWnd);[System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern bool IsIconic(IntPtr hWnd);[System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern int SetForegroundWindow(IntPtr hWnd);void FindAndOpenWindow(string Title)
    {
    IntPtr hWnd = FindWindow(null, Title);
    if (hWnd != IntPtr.Zero)
    {
    bool isIcon = IsIconic(hWnd);
    if ( !isIcon )
    {
    SetForegroundWindow(hWnd);
    }
    else
    {
    OpenIcon(hWnd);
    }
    }
    }