Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  Vb.net  >  正文 HOW TO: Set a Windows Hook in Visual C# .NET-Windo

HOW TO: Set a Windows Hook in Visual C# .NET-Windo

发布时间:2017-12-13   编辑:www.jquerycn.cn
jquery中文网为您提供HOW TO: Set a Windows Hook in Visual C# .NET-Windo等资源,欢迎您收藏本站,我们将为您提供最新的HOW TO: Set a Windows Hook in Visual C# .NET-Windo资源
HOW TO: Set a Windows Hook in Visual C# .NET
The information in this article applies to:
Microsoft .NET Framework SDK
Microsoft Visual C# .NET (2002)
IN THIS TASK
SUMMARY
Set a Mouse Hook
Global Hook Is Not Supported in .NET Framework
REFERENCES
SUMMARY
This article describes how to set a hook that is specific to a thread and to a hook procedure by using the mouse hook as an example. You can use hooks to monitor certain types of events. You can associate these events with a specific thread or with all of the threads in the same desktop as a calling thread.
back to the top
Set a Mouse Hook
To set a hook, call the SetWindowsHookEx function from the User32.dll file. This function installs an application-defined hook procedure in the hook chain that is associated with the hook.
To set a mouse hook and to monitor the mouse events, follow these steps:
Start Microsoft Visual Studio .NET.
On the File menu, point to New, and then click Project.
In the New Project dialog box, click Visual C# Projects under Project Types, and then click Windows Application under Templates. In the Name box, type ThreadSpecificMouseHook. Form1 is added to the project by default.
Add the following line of code in the Form1.cs file after the other using statements:
using System.Runtime.InteropServices;
Add following code in the Form1 class:
public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam);
//Declare hook handle as int.
static int hHook = 0;
//Declare mouse hook constant.

您可能感兴趣的文章:
HOW TO: Set a Windows Hook in Visual C# .NET-Windo
C# FAQ for C programmers
Performance Tips and Tricks in .NET Applications(一
Microsoft .NET vs. J2EE: How Do They Stack Up?
Java Security Notes (6)
用.net 2003开发Windows CE应用,解决与pocket pc通讯的问题
Table of Contents
Using TreeControl (TreeView) under Win32 API
C#中定时器控件Timer学习参考
[转]Go语言(golang)开源项目大全

[关闭]