实例介绍
【实例简介】
【实例截图】
【实例截图】
【核心代码】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Diagnostics; using System.Runtime.InteropServices; namespace Ecan { public class EcanDOS { //引入API函数 [DllImportAttribute( "user32.dll" )] private static extern int FindWindow( string ClassName, string WindowName); [DllImport( "user32.dll" )] private static extern int ShowWindow( int handle, int cmdShow); [DllImport( "winmm.dll" , EntryPoint = "mciSendString" , CharSet = CharSet.Auto)] private 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 void 弹出光驱() { mciSendString( "set CDAudio door open" , null , 127, 0); } public void 关闭光驱() { mciSendString( "set CDAudio door closed" , null , 127, 0); } public void 打开C盘() { Process.Start( "c:\\" ); } public void 打开D盘() { Process.Start( "d:\\" ); } public void 打开E盘() { Process.Start( "e:\\" ); } public void 打开F盘() { Process.Start( "f:\\" ); } public void 打开指定盘( string hardpath) { Process.Start(hardpath); } public void 打开Word() { Process.Start( @"C:\Program Files\Microsoft Office\OFFICE11\winword.exe" ); } public void 打开Excel() { Process.Start( @"C:\Program Files\Microsoft Office\OFFICE11\excel.exe" ); } public void 打开Access() { Process.Start( @"C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe" ); } public void 打开PowerPoint() { Process.Start( @"C:\Program Files\Microsoft Office\OFFICE11\powerpnt.exe" ); } public void 打开OutLook() { Process.Start( @"C:\Program Files\Microsoft Office\OFFICE11\outlook.exe" ); } public void 打开记事本() { Process.Start( "notepad.exe" ); } public void 打开计算器() { Process.Start( "calc.exe" ); } public void 打开DOS命令窗口() { Process.Start( "cmd.exe" ); } public void 打开注册表() { Process.Start( "regedit.exe" ); } public void 打开画图板() { Process.Start( "mspaint.exe" ); } public void 打开写字板() { Process.Start( "write.exe" ); } public void 打开播放器() { Process.Start( "mplayer2.exe" ); } public void 打开资源管理器() { Process.Start( "explorer.exe" ); } public void 打开任务管理器() { Process.Start( "taskmgr.exe" ); } public void 打开事件查看器() { Process.Start( "eventvwr.exe" ); } public void 打开系统信息() { Process.Start( "winmsd.exe" ); } public void 打开备份还原() { Process.Start( "ntbackup.exe" ); } public void 打开Windows版本() { Process.Start( "winver.exe" ); } public void 打开控制面板() { Process.Start( "rundll32.exe" , "shell32.dll,Control_RunDLL" ); } public void 打开控制面板辅助选项键盘() { Process.Start( "rundll32.exe" , "shell32.dll,Control_RunDLL access.cpl,,1" ); } public void 打开控制面板辅助选项声音() { Process.Start( "rundll32.exe" , "shell32.dll,Control_RunDLL access.cpl,,2" ); } public void 打开控制面板辅助选项显示() { Process.Start( "rundll32.exe" , "shell32.dll,Control_RunDLL access.cpl,,3" ); } public void 打开控制面板辅助选项鼠标() { Process.Start( "rundll32.exe" , "shell32.dll,Control_RunDLL access.cpl,,4" ); } public void 打开控制面板辅助选项常规() { Process.Start( "rundll32.exe" , "shell32.dll,Control_RunDLL access.cpl,,5" ); } public void 打开控制面板添加新硬件向导() { Process.Start( "rundll32.exe" , "shell32.dll,Control_RunDLL sysdm.cpl @1" ); } public void 打开控制面板添加新打印机向导() { Process.Start( "rundll32.exe" , "shell32.dll,SHHelpShortcuts_RunDLL AddPrinter" ); } public void 打开控制面板添加删除程序安装卸载面板() { Process.Start( "rundll32.exe" , "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,1" ); } public void 打开控制面板添加删除程序安装Windows面板() { Process.Start( "rundll32.exe" , "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,2" ); } public void 打开控制面板添加删除程序启动盘面板() { Process.Start( "rundll32.exe" , "shell32.dll,shell32.dll,Control_RunDLL appwiz.cpl,,3" ); } public void 打开建立快捷方式对话框() { Process.Start( "rundll32.exe" , " appwiz.cpl,NewLinkHere %1" ); } public void 打开日期时间选项() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL timedate.cpl,,0" ); } public void 打开时区选项() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL timedate.cpl,,1" ); } public void 建立公文包() { Process.Start( "rundll32.exe" , " syncui.dll,Briefcase_Create" ); } public void 打开复制软碟窗口() { Process.Start( "rundll32.exe" , " diskcopy.dll,DiskCopyRunDll" ); } public void 打开新建拨号连接() { Process.Start( "rundll32.exe" , " rnaui.dll,RnaWizard" ); } public void 打开显示属性背景() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL desk.cpl,,0" ); } public void 打开显示属性屏幕保护() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL desk.cpl,,1" ); } public void 打开显示属性外观() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL desk.cpl,,2" ); } public void 打开显示属性属性() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL desk.cpl,,3" ); } public void 打开格式化对话框() { Process.Start( "rundll32.exe" , " shell32.dll,SHFormatDrive" ); } public void 打开控制面板游戏控制器一般() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL joy.cpl,,0" ); } public void 打开控制面板游戏控制器进阶() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL joy.cpl,,1" ); } public void 打开控制面板键盘属性速度() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL main.cpl @1" ); } public void 打开控制面板键盘属性语言() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL main.cpl @1,,1" ); } public void 打开Windows打印机档案夹() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL main.cpl @2" ); } public void 打开Windows字体档案夹() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL main.cpl @3" ); } public void 打开控制面板输入法属性() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL main.cpl @4" ); } public void 打开添加新调制解调器向导() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL modem.cpl,,add" ); } public void 打开控制面板多媒体属性音频() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL mmsys.cpl,,0" ); } public void 打开控制面板多媒体属性视频() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL mmsys.cpl,,1" ); } public void 打开控制面板多媒体属性MIDI() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL mmsys.cpl,,2" ); } public void 打开控制面板多媒体属性CD音乐() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL mmsys.cpl,,3" ); } public void 打开控制面板多媒体属性设备() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL mmsys.cpl,,4" ); } public void 打开控制面板声音() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL mmsys.cpl @1" ); } public void 打开控制面板网络() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL netcpl.cpl" ); } public void 打开控制面板密码() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL password.cpl" ); } public void 打开控制面板电源管理() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL powercfg.cpl" ); } public void 打开控制面板区域设置属性区域设置() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL intl.cpl,,0" ); } public void 打开控制面板区域设置属性数字选项() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL intl.cpl,,1" ); } public void 打开控制面板区域设置属性货币选项() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL intl.cpl,,2" ); } public void 打开控制面板区域设置属性时间选项() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL intl.cpl,,3" ); } public void 打开控制面板区域设置属性日期选项() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL intl.cpl,,4" ); } public void 打开ODBC数据源管理器() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL odbccp32.cpl" ); } public void 打开控制面板系统属性常规() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL sysdm.cpl,,0" ); } public void 打开控制面板系统属性设备管理器() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL sysdm.cpl,,1" ); } public void 打开控制面板系统属性硬件配置() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL sysdm.cpl,,2" ); } public void 打开控制面板系统属性性能() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL sysdm.cpl,,3" ); } /*shutdown -s -t 3600 -f 一小时后强行关机 用强行主要怕有些程序卡住 关不了机 -s 关机 -r重启 -f强行 -t 时间 -a 取消关机 -l 注销 -i 显示用户界面 具体是什么试试就知道了*/ public void 关闭并重启计算机() { Process.Start( "shutdown.exe" , "-r" ); } public void 关闭计算机() { Process.Start( "shutdown.exe" , "-s -f" ); } //重载关闭计算机函数,可以设定倒计时 public void 关闭计算机( string time) { string s = "-s -t " time; Process.Start( "shutdown.exe" , s); } public void 注销计算机() { Process.Start( "shutdown.exe" , "-l" ); } public void 撤销关闭计算机() { Process.Start( "shutdown.exe" , "-a" ); } public void 打开桌面主旨面板() { Process.Start( "rundll32.exe" , " shell32.dll,Control_RunDLL themes.cpl" ); } public void 打开网址( string address) { Process.Start(address); } public void 运行程序( string name) { Process.Start(name); } public void 显示任务栏() { ShowWindow(FindWindow( "Shell_TrayWnd" , null ), SW_SHOW); } public void 隐藏任务栏() { ShowWindow(FindWindow( "Shell_TrayWnd" , null ), SW_HIDE); } public void 发送邮件( string address) { string s = "mailto:" address; Process.Start(s); } public void 发送邮件() { Process.Start( "mailto:feiyangqingyun@163.com" ); } public string 获取系统文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.System); return s; } public void 打开系统文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.System); Process.Start(s); } public string 获取ProgramFiles目录() { string s = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); return s; } public void 打开ProgramFiles目录() { string s = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); Process.Start(s); } public string 获取逻辑桌面() { string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); return s; } public void 打开逻辑桌面() { string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); Process.Start(s); } public string 获取启动程序组() { string s = Environment.GetFolderPath(Environment.SpecialFolder.Startup); return s; } public void 打开启动程序组() { string s = Environment.GetFolderPath(Environment.SpecialFolder.Startup); Process.Start(s); } public string 获取Cookies文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.Cookies); return s; } public void 打开Cookies文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.Cookies); Process.Start(s); } public string 获取Internet历史文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.History); return s; } public void 打开Internet历史文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.History); Process.Start(s); } public string 获取我的电脑文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); return s; } public void 打开我的电脑文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); Process.Start(s); } public string 获取MyMusic文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic); return s; } public void 打开MyMusic文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic); Process.Start(s); } public string 获取MyPictures文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); return s; } public void 打开MyPictures文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); Process.Start(s); } public string 获取StartMenu文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); return s; } public void 打开StartMenu文件夹() { string s = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); Process.Start(s); } } } |
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论