资源简介
领导经常视察,所以决定动手做个隐藏/显示打开的窗口及任务栏,查了许多资料,终于完成,其中涉及了:自定义热键、读写注册表、读写文本文件等技巧。希望能对有需要的同仁有所帮助。(用的是VS2008)

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;
namespace MyPro
{
public partial class Form1 : Form
{
private const int SWP_HIDEWINDOW = 0x80;
private const int SWP_SHOWWINDOW = 0x40;
[DllImport(“user32.dll“)]
public static extern bool SetWindowPos(
int hWnd // handle to window
int hWndInsertAfter // placement-order handle
short X // horizontal position
short Y // vertical position
short cx // width
short cy // height
uint uFlags // window-positioning options
);
[DllImport(“user32.dll“)]
public static extern int FindWindow(
string lpClassName // class name
string lpWindowName // window name
);
[DllImport(“user32.dll“ SetLastError = true)]
public static extern bool RegisterHotKey(
IntPtr hWnd //要定义热键的窗口的句柄
int id //定义热键ID(不能与其它ID重复)
KeyModifiers fsModifiers //标识热键是否在按Alt、Ctrl、Shift、Windows等键时才会生效
Keys vk //定义热键的内容
);
[DllImport(“user32.dll“ SetLastError = true)]
public static extern bool UnregisterHotKey(
IntPtr hWnd //要取消热键的窗口的句柄
int id //要取消热键的ID
);
[Flags()]
public enum KeyModifiers
{
None = 0
Alt = 1
Ctrl = 2
Shift = 4
WindowsKey = 8
}
public Form1()
{
InitializeComponent();
//注册热键Shift+S,Id号为100。HotKey.KeyModifiers.Shift也可以直接使用数字4来表示。
RegisterHotKey(Handle 100 KeyModifiers.Alt Keys.Z);
}
private void Form1_Activated(object sender EventArgs e)
{
//注册热键Shift+S,Id号为100。HotKey.KeyModifiers.Shift也可以直接使用数字4来表示。
RegisterHotKey(Handle 100 KeyModifiers.Alt Keys.Z);
}
private void button1_Click(object sender EventArgs e)
{
myTaskbar();
}
private void ToggleDesktop()
{
System.Diagnostics.Process Myprocess;
try
{
Myprocess = new System.Diagnostics.Process();
//打开MyDesktop.scf
Myprocess.StartInfo.FileName = “MyDesktop.scf“;
Myprocess.Sta
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 76 2008-10-24 17:41 MyPro\MyPro\bin\Debug\MyDesktop.scf
文件 823808 2008-10-24 20:06 MyPro\MyPro\bin\Debug\老板键.exe
文件 28160 2008-10-24 20:06 MyPro\MyPro\bin\Debug\老板键.pdb
文件 14328 2008-10-24 20:06 MyPro\MyPro\bin\Debug\老板键.vshost.exe
目录 0 2008-10-24 20:06 MyPro\MyPro\bin\Debug
文件 77 2008-10-24 19:40 MyPro\MyPro\bin\Release\MyDesktop.scf
文件 14328 2008-10-24 19:54 MyPro\MyPro\bin\Release\MyPro.vshost.exe
文件 490 2007-07-21 01:33 MyPro\MyPro\bin\Release\MyPro.vshost.exe.manifest
文件 823808 2008-10-24 20:06 MyPro\MyPro\bin\Release\老板键.exe
文件 26112 2008-10-24 20:06 MyPro\MyPro\bin\Release\老板键.pdb
文件 14328 2008-10-24 20:05 MyPro\MyPro\bin\Release\老板键.vshost.exe
文件 490 2007-07-21 01:33 MyPro\MyPro\bin\Release\老板键.vshost.exe.manifest
目录 0 2008-10-24 20:06 MyPro\MyPro\bin\Release
目录 0 2008-10-24 18:53 MyPro\MyPro\bin
文件 323590 2006-05-07 03:58 MyPro\MyPro\browser.ico
文件 323590 2006-05-07 03:58 MyPro\MyPro\bug.ico
文件 323590 2006-05-07 03:58 MyPro\MyPro\cookie.ico
文件 9361 2008-10-24 20:04 MyPro\MyPro\Form1.cs
文件 5064 2008-10-24 20:03 MyPro\MyPro\Form1.Designer.cs
文件 977275 2008-10-24 20:03 MyPro\MyPro\Form1.resx
文件 3882 2008-10-24 20:05 MyPro\MyPro\MyPro.csproj
文件 1620 2008-10-24 20:06 MyPro\MyPro\obj\Debug\MyPro.csproj.FileListAbsolute.txt
文件 847 2008-10-24 20:06 MyPro\MyPro\obj\Debug\MyPro.csproj.GenerateResource.Cache
文件 648048 2008-10-24 20:06 MyPro\MyPro\obj\Debug\MyPro.Form1.resources
文件 180 2008-10-24 20:06 MyPro\MyPro\obj\Debug\MyPro.Properties.Resources.resources
目录 0 2008-10-24 18:53 MyPro\MyPro\obj\Debug\Refactor
目录 0 2008-10-24 18:53 MyPro\MyPro\obj\Debug\TempPE
文件 823808 2008-10-24 20:06 MyPro\MyPro\obj\Debug\老板键.exe
文件 28160 2008-10-24 20:06 MyPro\MyPro\obj\Debug\老板键.pdb
目录 0 2008-10-24 20:06 MyPro\MyPro\obj\Debug
............此处省略24个文件信息
- 上一篇:一个用C#绘制的动态时钟自定义控件
- 下一篇:ASP.NET写的转盘抽奖程序
相关资源
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
评论
共有 条评论