Microsoft KB Archive/925168

= Error message when you run a .NET Framework 1.1-based application on a Windows Vista-based computer: &quot;Hook cannot be created&quot; =

Article ID: 925168

Article Last Modified on 5/21/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1

-



SYMPTOMS
When you run a Microsoft .NET Framework 1.1-based application on a Microsoft Windows Vista-based computer, you use a System.Windows.Forms.SendKeys class in the application. If the User Account Control (UAC) is enabled, the application throws a security exception. Additionally, you receive the following error message:

Hook cannot be created



CAUSE
This problem occurs because the .NET Framework 1.1 creates a global journal hook for the SendKeys class. This hook does not have permissions to log on to Windows Vista if the UAC service is started.



RESOLUTION
To resolve this problem, download a General Distribution Release (GDR) from the Microsoft Windows Update and Download Center. The following file is available for download from the Microsoft Download Center:

Download the KB925168 package now.

For more information about how to download Microsoft support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to obtain Microsoft support files from online services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.

Prerequisites
You must have the .NET Framework 1.1 installed to apply this GDR.

GDR replacement information
This GDR does not replace any other GDRs that are installed on the computer.

Restart requirement
You do not have to restart the computer after you apply this GDR.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
The GDR updates the .NET Framework 1.1. After you apply the GDR, the .NET Framework 1.1 calls the User32 SendInput API instead of creating the global journal hook. By default, the SendKeys class tries to use the global journal hook the first time that you run an application on a Windows Vista-based computer. If the SendKeys class does not use the global journal hook, the User32 SendInput API is called to send the keystrokes. All later calls to the SendKeys class go directly to the User32 SendInput API. Therefore, the SendKeys class can run correctly on a Windows Vista-based computer.

Note This GDR does not affect operating systems that do not have the UAC service.

You can append the application configuration file to configure the System.Windows.Forms.SendKeys.Send method. If you append the following configuration code to the application configuration file, you force the use of the global journal hook to send keystrokes on all platforms.    Note If you append this configuration code, the SendKeys class throws a security exception when the application runs on a Windows Vista-based computer where the UAC service is started.

If you append the following configuration code to the application configuration file, you force the SendKeys class to call the User32 SendInput API to send keystrokes on all platforms.    Note If you append this configuration code, the SendKeys class always calls the User32 SendInput API on all platforms. If an application configuration file already exists, you can merely append the AppSetting section to the configuration file.

For more information about application configuration files, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/ms229689(vs.71).aspx

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Keywords: kberrmsg kbqfe kbpubtypekc KB925168

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.