Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 251139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:34:11+00:00 2026-05-11T21:34:11+00:00

I want to bring another application into the foreground, however, I only have a

  • 0

I want to bring another application into the foreground, however, I only have a partial name of the window. Back in the day, I’d hook into the EnumWindows API and look for what I needed.

Is there a way to do this better in C#? An example would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:34:11+00:00Added an answer on May 11, 2026 at 9:34 pm

    This should do the job:

    [DllImport("user32.dll", EntryPoint="SystemParametersInfo")]  
    public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);  
    
    [DllImport("user32.dll", EntryPoint="SetForegroundWindow")]  
    public static extern bool SetForegroundWindow(IntPtr hWnd);  
    
    [DllImport("User32.dll", EntryPoint="ShowWindowAsync")]  
    private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);  
    private const int WS_SHOWNORMAL = 1;  
    private const int SW_SHOWMAXIMIZED = 3;
    
    [DllImport("user32.dll")] 
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
    
    private struct WINDOWPLACEMENT
    {
      public int length;
      public int flags;
      public int showCmd;
      public System.Drawing.Point ptMinPosition;
      public System.Drawing.Point ptMaxPosition;
      public System.Drawing.Rectangle rcNormalPosition;
    }
    
    Process[] processes = Process.GetProcesses();  
    foreach(Process p in processes){              
     if(p.MainWindowTitle.Contains("nice_title")){
      WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
      placement.length = Marshal.SizeOf(placement);
      GetWindowPlacement(p.MainWindowHandle, ref placement);
    
      int proposedPlacement = wp.showCmd;
    
      if (wp.showCmd == SW_SHOWMINIMIZED)
        proposedPlacement = SW_SHOWMAXIMIZED;
    
      SystemParametersInfo( (uint) 0x2001, 0, 0, 0x0002 | 0x0001);  
      ShowWindowAsync(p.MainWindowHandle, proposedPlacement);  
      SetForegroundWindow(p.MainWindowHandle);  
      SystemParametersInfo( (uint) 0x2001, 200000, 200000, 0x0002 | 0x0001);    
    
     }                                             
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to bring up a file dialog in Java that defaults to the
I have a huge query that is being made dynamically, but I want the
I have a UITabBar Application with two views that load large amounts of data
I have developed an application that pulls X amount of records from my database
I have a website project that is consuming user controls from another shared project.
We have an Oracle Enterprise database in production and another instance that we use
I have a application which uses socket connection to send and receive data from
I have a system that we have recently developed - a web application over
I want to know if the page is being accessed via http or https
I want to ran the following script on text files that are being committed:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.