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 161849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:17:11+00:00 2026-05-11T11:17:11+00:00

I have an application that aids people with disabilities. In order to work, it

  • 0

I have an application that aids people with disabilities. In order to work, it tracks the what window is currently in the foreground. Normally, I use this function to get process executable.

bool GetWindowProcessExe2(HWND hwnd, wxString& process_exe)                          //LPTSTR buf, DWORD size) { DWORD result = 0; DWORD pid = 0; GetWindowThreadProcessId(hwnd, &pid); if (HANDLE process =     OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid)) {   char buff[512];   LPTSTR pbuff = buff;   result = GetModuleFileNameEx(process, 0, pbuff, 512);   if(result == 0)   {     //failed.     wxLogError('GetModuleFileNameEx failed with error code %d', GetLastError());   }   CloseHandle(process);   process_exe = fromCString(pbuff); }  return result > 0 ? true : false; 

}

Unfortunately, if the foreground window is the Vista file manager window (the window that opens when you click Start->Computer), GetModuleFileNameEx() fails with error code 299 which says I don’t have privileges for this action. My code works for any regular application but not for the windows built in window (the file explorer). I need to know when this window is forefront. Is there another way to do it? I tried reading the window title but that just returns the current directory being shown. Any ideas?

  • 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. 2026-05-11T11:17:11+00:00Added an answer on May 11, 2026 at 11:17 am

    I’m not sure why this isn’t working for explorer, but error 299 is ERROR_PARTIAL_COPY, meaning that attempting to read the module name out of explorer is failing.

    On Vista, prefer QueryProcessImageFileName and only open the process with PROCESS_QUERY_LIMITED_INFORMATION – your code will work in more cases.

    WCHAR exeName[512]; DWORD cchExeName = 512; HANDLE process = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid); QueryFullProcessImageName(process, 0, exeName, &cchExeName); 

    EDIT: I also got ERROR_PARTIAL_COPY with your code running on 64-bit, but only when the querying process was 32-bit. 64-bit/64-bit worked fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that I am just migrating to Azure. Currently I use
I have an application that goes like this F5 load balancer - IHS(a&b) -
I have application that use mysql database, but now i need to port it
I have application that has to check multiple data from user table, in order
I have an application that reads 'timed' data out of a file; currently, my
I have an application that is a .net 4.0 app and needs to use
I have application that have button i want when click this button every 1
I have application that received data via HTTP POST requests. I'm trying to use
I have an application that I want to use Visual Styles and I have
I have application that makes different queries with different results so the caching in

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.