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

  • SEARCH
  • Home
  • 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 9216167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:21:35+00:00 2026-06-18T02:21:35+00:00

I need handle another running application by name, id, or process handle. I get

  • 0

I need handle another running application by name, id, or process handle. I get the ID and Process handles but I don’t know how get handle of window to change external program title.

There is my code:

BOOL CFindProcess::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PROCESS);
    HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    PROCESSENTRY32 proc;
    proc.dwSize = sizeof(PROCESSENTRY32);
    if (Process32First(hSnap, &proc)){
        pComboBox->AddString(proc.szExeFile);
        while (Process32Next(hSnap, &proc)){
            if (0!=wcscmp(proc.szExeFile, L"svchost.exe"))
                pComboBox->AddString(proc.szExeFile);
            if (wcscmp(proc.szExeFile, L"notepad.exe") == 0){
                HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proc.th32ProcessID);
                GetProcessId(hProcess);
                AfxMessageBox(L"Handeled");
                //SetWindowText(hProcess, L"Weather");
                CloseHandle(hProcess);
            }
        }
    }
    CloseHandle(hSnap);
    return TRUE;
}

my question is how get window handle of notepad.exe by name or ID, Process handles with MFC?

  • 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-06-18T02:21:37+00:00Added an answer on June 18, 2026 at 2:21 am

    This code demonstrates what Jerry is referring to:

    struct MYFINDSTRUCT
    {
        DWORD dwPID;
        HWND hWnd;
    };
    
    BOOL CALLBACK MyWndEnum(HWND hwnd,LPARAM lParam)
    {
        MYFINDSTRUCT* pP = (MYFINDSTRUCT*)lParam;
            DWORD dwPID = 0;
        GetWindowThreadProcessId(hwnd,&dwPID);
        if(dwPID==pP->dwPID)
        {
            pP->hWnd = hwnd;
            return 0;
        }
        return 1;
    }
    
    HWND GetProcessHWND(unsigned int nPID)
    {
        MYFINDSTRUCT p;
        p.hWnd = 0;
        p.dwPID = nPID;
        EnumWindows(MyWndEnum,(LPARAM)&p);
        return p.hWnd;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to handle events of two different types but I'm running into the
I need to handle another windows application programatically, searching google I found a sample
I wish to store the Window handle of a running instance of an application
I need to handle strings in my php script using regular expressions. But there
In our application we need to handle request volumes in excess of 5,000 requests
I need my activity to handle HOME button press with a receiver programmatically, but
I want to send keyboard input to a window in another process, without bringing
For a project I need to handle audio in an iPhone app quite special
I'm writing a batch (.bat) script and I need to handle the case in
I have a problem with NCurses ... i need to handle all keys like

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.