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

推荐订阅源

Help Net Security
Help Net Security
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
C
Check Point Blog
M
MIT News - Artificial intelligence
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
U
Unit 42
D
Docker
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
H
Help Net Security
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
Cloudbric
Cloudbric
Blog — PlanetScale
Blog — PlanetScale
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
S
Security @ Cisco Blogs
V
Visual Studio Blog
The Last Watchdog
The Last Watchdog
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Cyber Attacks, Cyber Crime and Cyber Security
Last Week in AI
Last Week in AI
爱范儿
爱范儿
博客园 - 聂微东
S
Securelist
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
V
Vulnerabilities – Threatpost
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
O
OpenAI News
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - rangeliu

批判下微软的sql面试题 SQL Server 报表系统导出txt格式方法 Reporting Service报表纵向单元格合并 SSAS中命名集(SET)的使用 返回指定成员所有下级成员的MDX语句 MDX学习——初始MDX [收藏]Oracle 性能优化 [收藏]使用XML技術實現OWC對數據庫的展示 十六進制的字符串轉換為double類型 [收藏]递归算出两个数字之间所有数字之和 [收藏]String与string的区别 [收藏]about协议的妙用 [收藏]中英文颜色对照表 [收藏]C# WinForm程序如何与JS交互 [转载]动态调用WebService(C#) [转载] .NET脏字过滤算法 [转载]使用Response.Filter过滤非法词汇 [转载]asp.net面试集合 [转载]WEB开发碰到的问题及经验十八则
[收藏]在C#程序中使用系统热键
rangeliu · 2009-01-24 · via 博客园 - rangeliu

1.首先引入System.Runtime.InteropServices
using System.Runtime.InteropServices; 

2.在类内部声明两个API函数,它们的位置和类的成员变量等同.

4.在类的构造函数出注册系统热键
示例,下例注册了四个热键:

Code


5.重写WndProc()方法,通过监视系统消息,来调用过程
示例:

Code


5.不用说,我们接下来需要实现ProcessHotkey函数:

Code

很明显接下来分别实现函数DecreseVolumnb(); 和AddVolumnb(); 即可.

6.最后别忘了在程序退出时取消热键的注册

Code

Code
[DllImport("user32.dll")] //申明API函数
public static extern bool RegisterHotKey( 
IntPtr hWnd, 
// handle to window 
int id, // hot key identifier 
uint fsModifiers, // key-modifier options 
Keys vk // virtual-key code 
); 

[DllImport(

"user32.dll")] //申明API函数 
public static extern bool UnregisterHotKey( 
IntPtr hWnd, 
// handle to window 
int id // hot key identifier 
); 


3.定义一个KeyModifiers的枚举,以便出现组合键

Code