从.NET中使用非托管的DLL系统范围壳牌挂钩 [英] System Wide Shell Hook from .NET using Unmanaged DLL

查看:228
本文介绍了从.NET中使用非托管的DLL系统范围壳牌挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用了与成功近以下CodeProject上的文章中提供的代码,但它似乎只在Vista / 7(我猜是因为UAC)的部分工作。它适用于当前线程,但它不拾取系统范围内的活动。我已经在清单尝试添加requireAdministrator并签署了双方非托管和托管组件,而不会出现帮助

I have used the code supplied in the following CodeProject article in the past with success, but it only seems to partially work on Vista/7 (I'm guessing because of UAC). It works for the current thread, but it doesn't pick up system wide activity. I've tried adding requireAdministrator in the manifests and signing both the unmanaged and managed assemblies, and that doesn't appear to help.

使用窗口消息来实现全球系统钩子在C#

我的主要目标是使用SetWindowsHookEx函数赶在非托管装配HSHELL_WINDOWCREATED和HSHELL_WINDOWDESTROYED的消息,并通知了C#应用程序,以便它可以使用实时信息。它基本上只需要知道每当创建或系统被破坏的一个窗口。

My main goal is to use SetWindowsHookEx to catch the HSHELL_WINDOWCREATED and HSHELL_WINDOWDESTROYED messages in the unmanaged assembly, and notify the C# application so that it can use the information in real time. It basically just needs to know whenever a window is created or destroyed in the system.

我还发现了一个示例应用程序,这是纯粹的C / C ++,在Vista中工作得很好。/ 7,但我真的不希望有,因为我更喜欢C#写的C / C ++整个应用程序

I also found an example application that is pure C/C++ that works just fine in Vista/7, but I really don't want to have to write the entire application in C/C++ as I prefer C#.

系统全局钩子的例子,工程

任何人知道如何修复代码的第一个CodeProject上的文章中,这样它可以在Vista / 7的呢?还是有办法,我可以做到这一点任何其他的例子,而不在C#创建定时器和类似的黑客?

Anyone know how to fix the code in the first CodeProject article so that it works on Vista/7 as well? Or have any other examples of ways I can do this without creating timers and similar hacks in C#?

谢谢,
马克

推荐答案

看看我的程序:的 http://wpfklip.codeplex.com
我已经实现了全系统的壳钩因此该方案是能够赶上创建的窗口,激活等。而且它用C#

have a look at my program: http://wpfklip.codeplex.com. I've implemented system-wide shell hook so the program is able to catch window created, activated and so on. And it's written in c#

这篇关于从.NET中使用非托管的DLL系统范围壳牌挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆