Using the CorrectShellExecuteHWND Fix
Published: June 11, 2010
Updated: June 11, 2010
Applies To: Windows 7, Windows Vista
This section includes information about using the CorrectShellExecuteHWND compatibility fix, including the issue details, the intercepted APIs, and the recommended fix for a permanent solution.
CorrectShellExecuteHWND fixes an issue whereby an application passes a bad handle to a window (HWnd) value into an API call to ShellExecute*, which results in user account control (UAC) elevation. In this situation, the bad HWnd value causes Windows Vista to fail to prompt the end user for elevation and instead flashes the elevation request in the taskbar.
This compatibility fix inspects the HWnd value by using the IsWindow(HWND) API call. If the HWnd value appears to be invalid, the compatibility fix replaces the value with a currently active HWnd value, but only if the HWnd appears in the current process.
Investigating the Issue
Application-related issues that can be resolved by applying the CorrectShellExecuteHWND fix are typically detected when the taskbar starts to flash without changing the window focus. You can confirm that this issue is related to the CorrectShellExecuteHWND fix by performing these steps:
Set a breakpoint on ShellExecute* and then check the HWnd argument.
Search for the HWnd value by using the Spy++ utility that is distributed with Visual Studio.
The following APIs are intercepted by the CorrectShellExecuteHWND compatibility fix.
Fixing Your Code
Applications should be modified so that the code calling ShellExecute* passes the currently active HWnd value.