惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tor Project blog
B
Blog RSS Feed
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
GbyAI
GbyAI
N
Netflix TechBlog - Medium
博客园 - 司徒正美
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
SecWiki News
SecWiki News
V
Vulnerabilities – Threatpost
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Register - Security
The Register - Security
Cisco Talos Blog
Cisco Talos Blog
Martin Fowler
Martin Fowler
A
About on SuperTechFans
S
Security @ Cisco Blogs
T
Tenable Blog
C
Check Point Blog
N
News and Events Feed by Topic
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Attack and Defense Labs
Attack and Defense Labs
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cisco Blogs
P
Palo Alto Networks Blog
V
V2EX
博客园 - 聂微东
Project Zero
Project Zero
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
N
News | PayPal Newsroom
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
小众软件
小众软件
Application and Cybersecurity Blog
Application and Cybersecurity Blog
人人都是产品经理
人人都是产品经理
V2EX - 技术
V2EX - 技术
I
Intezer
L
LINUX DO - 最新话题

博客园 - 萧萧空间

Windows 2003,XP安装Windows Phone 7 从海量数据中找出中位数(转) 界面开发(五)--- 界面优化 界面开发(四)--- 还窗体的新面貌 界面开发(三)--- 设置窗体的Region 界面开发(一)--- Hook所有的窗体 界面开发概述 ExtJs扩展之GroupPropertyGrid ExtJs之带图片的下拉列表框 寻找第K大的数的方法总结 我自己的ColorSpy Office 2010 beta版安装 Java反编译工具JD ExtJs Grid Drag Drap Splash窗体(ProgressWindowForm修改) 异步窗体实现操作进度(ProgressWindow) 线程封装组件(BackgroundWorker)和线程(Thread) 多线程开发 NSIS 的使用心得
界面开发(二)--- NativeWindow
萧萧空间 · 2010-03-19 · via 博客园 - 萧萧空间

     NativeWindow是.net Framework提供的一个底层的类。微软官方的解释为:NativeWindow Provides a low-level encapsulation of a window handle and a window procedure.说道这些也相当于没有说,因为NativeWindow到底是干什么的也没有说清楚,意思就是一个低级别的对窗体句柄和窗体过程的一个封装。后来查询了很多的资料才明白了其中的意义。

     资料来源:

     http://www.diybl.com/course/4_webprogram/asp.net/netjs/2007921/72804.html

     这个讲解的是《利用NativeWindow监视WndProc消息》,这篇内容比较长,而且页数比较多,经过自己努力和耐心,终于完成了其中的例子,代码下载地址为:/Files/zhjp11/皮肤/NativeWindowApplication.rar

     http://www.codeproject.com/KB/dialog/OpenFileDialogEx.aspx

     这篇来自CodeProject,老外写的代码就是比较有水平。将Windows 的OpenFileDialog子类化,显示成了自定义的OpenFileDialog,而且添加了很多的事件。相当的佩服。

     经过这两篇的细心阅读,终于了解了NativeWindow的作用,NativeWindow就是提供了底层的封装,提供了AssignHandle和RealeseHandle这两个方法,主要就是对注册了窗体句柄的窗体进行Hook,将窗体的事件经过自己处理后交给Windows处理。使用Refector.net查看了NativeWindowAssignHandle这个方法,也验证了我这个说法。在AssignHandle中有这样一段代码:

userDefWindowProc = UnsafeNativeMethods.GetProcAddress(new HandleRef(null,UnsafeNativeMethods.GetModuleHandle("user32.dll")), lpProcName); 

     对Win32开发的也许都知道这段代码的意义,他也是Hook的一种。不过是更加高级的Hook方式。这里就不在细说,我们现在只要知道他可以对我们进行注册的窗体进行Hook,可以将自己的代码加载到我们想要的位置就可以了。

     然后我就使用NativeWindow获取所有的窗体的所有事件,然后输出Hook到的时间,结果图如下:

                                              

     下载代码如下:/Files/zhjp11/皮肤/SkinEngines20100319.rar