Win32 API
2010-06-27 12:08
197 查看
//引入API函数
[DllImportAttribute("user32.dll")]
public static extern int FindWindow(string ClassName,string WindowName);
[DllImport("user32.dll")]
public static extern int ShowWindow(int handle, int cmdShow);
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(string lpstrCommand, string lpstrReturnstring, int uReturnLength, int hwndCallback);
private const int SW_HIDE=0;//API参数表示隐藏窗口
private const int SW_SHOW=5;//API参数表示用当前的大小和位置显示窗口
public static void 弹出光驱()
{
mciSendString("set CDAudio door open", null, 127, 0);
}
public static void 关闭光驱()
{
mciSendString("set CDAudio door closed", null, 127, 0);
}
public static void 打开C盘()
{
Process.Start("c:\\");
}
public static void 打开D盘()
{
Process.Start("d:\\");
}
public static void 打开E盘()
{
Process.Start("e:\\");
}
public static void 打开F盘()
{
Process.Start("f:\\");
}
public static void 打开指定盘(string hardpath)
{
Process.Start(hardpath);
}
public static void 打开Word()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\winword.exe");
}
public static void 打开Excel()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\excel.exe");
}
public static void 打开Access()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe");
}
public static void 打开PowerPoint()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\powerpnt.exe");
}
public static void 打开OutLook()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\outlook.exe");
}
public static void 打开记事本()
{
Process.Start("notepad.exe");
}
public static void 打开计算器()
{
Process.Start("calc.exe");
}
public static void 打开DOS命令窗口()
{
Process.Start("cmd.exe");
}
public static void 打开注册表()
{
Process.Start("regedit.exe");
}
public static void 打开画图板()
{
Process.Start("mspaint.exe");
}
public static void 打开写字板()
{
Process.Start("write.exe");
}
public static void 打开播放器()
{
Process.Start("mplayer2.exe");
}
public static void 打开资源管理器()
{
Process.Start("explorer.exe");
}
public static void 打开任务管理器()
{
Process.Start("taskmgr.exe");
}
public static void 打开事件查看器()
{
Process.Start("eventvwr.exe");
}
public static void 打开系统信息()
{
Process.Start("winmsd.exe");
}
public static void 打开备份还原()
{
Process.Start("ntbackup.exe");
}
public static void 打开Windows版本()
{
Process.Start("winver.exe");
}
public static void 打开控制面板()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL");
}
public static void 打开控制面板辅助选项键盘()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,1");
}
public static void 打开控制面板辅助选项声音()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,2");
}
public static void 打开控制面板辅助选项显示()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,3");
}
public static void 打开控制面板辅助选项鼠标()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,4");
}
public static void 打开控制面板辅助选项常规()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,5");
}
public static void 打开控制面板添加新硬件向导()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL sysdm.cpl @1");
}
public static void 打开控制面板添加新打印机向导()
{
Process.Start("rundll32.exe", "shell32.dll,SHHelpShortcuts_RunDLL AddPrinter");
}
public static void 打开控制面板添加删除程序安装卸载面板()
{
Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,1");
}
public static void 打开控制面板添加删除程序安装Windows面板()
{
Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,2");
}
public static void 打开控制面板添加删除程序启动盘面板()
{
Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,3");
}
public static void 打开建立快捷方式对话框()
{
Process.Start("rundll32.exe"," appwiz.cpl,NewLinkHere %1");
}
public static void 打开日期时间选项()
{
Process.Start("rundll32.exe"," shell32.dll,Control_RunDLL timedate.cpl,,0");
}
public static void 打开时区选项()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL timedate.cpl,,1");
}
public static void 建立公文包()
{
Process.Start("rundll32.exe"," syncui.dll,Briefcase_Create");
}
public static void 打开复制软碟窗口()
{
Process.Start("rundll32.exe"," diskcopy.dll,DiskCopyRunDll");
}
public static void 打开新建拨号连接()
{
Process.Start("rundll32.exe"," rnaui.dll,RnaWizard");
}
public static void 打开显示属性背景()
{
Process.Start("rundll32.exe"," shell32.dll,Control_RunDLL desk.cpl,,0");
}
public static void 打开显示属性屏幕保护()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,1");
}
public static void 打开显示属性外观()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,2");
}
public static void 打开显示属性属性()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,3");
}
[DllImportAttribute("user32.dll")]
public static extern int FindWindow(string ClassName,string WindowName);
[DllImport("user32.dll")]
public static extern int ShowWindow(int handle, int cmdShow);
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(string lpstrCommand, string lpstrReturnstring, int uReturnLength, int hwndCallback);
private const int SW_HIDE=0;//API参数表示隐藏窗口
private const int SW_SHOW=5;//API参数表示用当前的大小和位置显示窗口
public static void 弹出光驱()
{
mciSendString("set CDAudio door open", null, 127, 0);
}
public static void 关闭光驱()
{
mciSendString("set CDAudio door closed", null, 127, 0);
}
public static void 打开C盘()
{
Process.Start("c:\\");
}
public static void 打开D盘()
{
Process.Start("d:\\");
}
public static void 打开E盘()
{
Process.Start("e:\\");
}
public static void 打开F盘()
{
Process.Start("f:\\");
}
public static void 打开指定盘(string hardpath)
{
Process.Start(hardpath);
}
public static void 打开Word()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\winword.exe");
}
public static void 打开Excel()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\excel.exe");
}
public static void 打开Access()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe");
}
public static void 打开PowerPoint()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\powerpnt.exe");
}
public static void 打开OutLook()
{
Process.Start(@"C:\Program Files\Microsoft Office\OFFICE11\outlook.exe");
}
public static void 打开记事本()
{
Process.Start("notepad.exe");
}
public static void 打开计算器()
{
Process.Start("calc.exe");
}
public static void 打开DOS命令窗口()
{
Process.Start("cmd.exe");
}
public static void 打开注册表()
{
Process.Start("regedit.exe");
}
public static void 打开画图板()
{
Process.Start("mspaint.exe");
}
public static void 打开写字板()
{
Process.Start("write.exe");
}
public static void 打开播放器()
{
Process.Start("mplayer2.exe");
}
public static void 打开资源管理器()
{
Process.Start("explorer.exe");
}
public static void 打开任务管理器()
{
Process.Start("taskmgr.exe");
}
public static void 打开事件查看器()
{
Process.Start("eventvwr.exe");
}
public static void 打开系统信息()
{
Process.Start("winmsd.exe");
}
public static void 打开备份还原()
{
Process.Start("ntbackup.exe");
}
public static void 打开Windows版本()
{
Process.Start("winver.exe");
}
public static void 打开控制面板()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL");
}
public static void 打开控制面板辅助选项键盘()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,1");
}
public static void 打开控制面板辅助选项声音()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,2");
}
public static void 打开控制面板辅助选项显示()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,3");
}
public static void 打开控制面板辅助选项鼠标()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,4");
}
public static void 打开控制面板辅助选项常规()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL access.cpl,,5");
}
public static void 打开控制面板添加新硬件向导()
{
Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL sysdm.cpl @1");
}
public static void 打开控制面板添加新打印机向导()
{
Process.Start("rundll32.exe", "shell32.dll,SHHelpShortcuts_RunDLL AddPrinter");
}
public static void 打开控制面板添加删除程序安装卸载面板()
{
Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,1");
}
public static void 打开控制面板添加删除程序安装Windows面板()
{
Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,2");
}
public static void 打开控制面板添加删除程序启动盘面板()
{
Process.Start("rundll32.exe", "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,3");
}
public static void 打开建立快捷方式对话框()
{
Process.Start("rundll32.exe"," appwiz.cpl,NewLinkHere %1");
}
public static void 打开日期时间选项()
{
Process.Start("rundll32.exe"," shell32.dll,Control_RunDLL timedate.cpl,,0");
}
public static void 打开时区选项()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL timedate.cpl,,1");
}
public static void 建立公文包()
{
Process.Start("rundll32.exe"," syncui.dll,Briefcase_Create");
}
public static void 打开复制软碟窗口()
{
Process.Start("rundll32.exe"," diskcopy.dll,DiskCopyRunDll");
}
public static void 打开新建拨号连接()
{
Process.Start("rundll32.exe"," rnaui.dll,RnaWizard");
}
public static void 打开显示属性背景()
{
Process.Start("rundll32.exe"," shell32.dll,Control_RunDLL desk.cpl,,0");
}
public static void 打开显示属性屏幕保护()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,1");
}
public static void 打开显示属性外观()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,2");
}
public static void 打开显示属性属性()
{
Process.Start("rundll32.exe", " shell32.dll,Control_RunDLL desk.cpl,,3");
}
相关文章推荐
- Win32串口API
- 拦截win32 API 调用(上)
- 系统理解Win32 API和MFC
- vba使用win32 API(GetOpenFileName )实现打开文件对话框
- 窗口启动特效,使用win32 api
- vba使用win32 API(GetOpenFileName )实现打开文件对话框
- 如何获取设备描述表句柄--WIN32 api
- Win32调试API学习心得(二)
- InternetOpen\InternetOpenUrl\InternetReadFile 等相关Win32 网络API 使用详细说明
- win32的时间api
- 从Win32 API封装Thread类[2]
- 重温WIN32 API ------ 窗口上绘制位图文件
- Win32 API消息函数:SendMessage
- 在VC++6.0中用Win32 API实现串行通信
- Win32 API与.NET Framework
- 跟我一起学Windows界面封装(一) 之 基础篇:Win32 API
- java 调用win32 api 学习总结
- WIN32 API 文件设备IO操作函数解析
- Win32 SDK基础(6)—— 窗口类的查找过程和相关API
- Win32 API下的多线程编程