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

This article has been archived. It is offered "as is" and will no longer be updated.
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:

DownloadDownload 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 "Applies to" 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.
<configuration>  <appSettings>    <add key="SendKeys" value="JournalHook"/>  </appSettings></configuration>
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.
<configuration>  <appSettings>    <add key="SendKeys" value="SendInput"/>  </appSettings></configuration>
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: 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
Properties

Article ID: 925168 - Last Review: 12/09/2015 07:08:16 - Revision: 2.0

Microsoft .NET Framework 1.1

  • kbnosurvey kbarchive kberrmsg kbqfe KB925168
Feedback