在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
我们经常会遇到在Winform或是WPF中点击链接或按钮打开某个指定的网址, 或者是需要打开电脑中某个指定的硬盘分区及文件夹, 甚至是"控制面板"相关的东西, 那么如何做呢? 答案是使用System.Diagnostics.Process.Start()。它的作用是调用外部的命令。 先来看看它的调用方法: Process.Start ();
Process.Start (ProcessStartInfo);
Process.Start (String);
Process.Start (String, String);
Process.Start (String, String, SecureString, String);
Process.Start (String, String, String, SecureString, String);
比如: System.Diagnostics.Process ie = new System.Diagnostics.Process(); ie.StartInfo.FileName = "IEXPLORE.EXE"; ie.StartInfo.Arguments = @"http://www.google.com"; ie.Start(); 简洁的调用方式: System.Diagnostics.Process.Start("http://www.google.com"); 当然,你还可以使用其他浏览器,如傲游而不是IE: string mathonPath = @"C:\Program Files\Maxthon\\Maxthon.exe"; System.Diagnostics.Process p = new System.Diagnostics.Process(); //设定程序名 p.StartInfo.FileName = mathonPath; p.StartInfo.Arguments = @"c:\"; p.Start(); 如果你想用资源管理器打开C:\ ,那么可以这样做: System.Diagnostics.Process.Start("explorer.exe", @"c:\"); 更有人可能会问:“我要打开“添加或删除程序”的面板或控制面板相关内容,可以吗?”答案是肯定的! 如何做?答案是调用rundll32.exe,比如: System.Diagnostics.Process.Start("rundll32.exe", @"shell32.dll,Control_RunDLL appwiz.cpl,,1"); 其中后面的"shell32.dll,Control_RunDLL appwiz.cpl,,1"是调用命令所需的参数了。 这里说明一下,这类似于在Delphi中使用: ShellExecute(Handle,'open','rundll32.exe','shell32.dll,Control_RunDLL sysdm.cpl',nil,SW_SHOW); WinExec('rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl',SW_SHOW); 关于rundll32.exe的用途 -------------------------------------------------------------------------------- 命令列:rundll32.exe user.exe,restartwindows 命令列:rundll32.exe user.exe,exitwindows 命令列: rundll32.exe shell32.dll,Control_RunDLL 命令列: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,1 命令列: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,2 命令列: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,3 命令列: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,4 命令列: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,5 命令列: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl @1 命令列: rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter 命令列: rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,1 命令列: rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2 命令列: rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,3 命令列: rundll32.exe syncui.dll,Briefcase_Create 命令列: rundll32.exe diskcopy.dll,DiskCopyRunDll 命令列: rundll32.exe apwiz.cpl,NewLinkHere %1 命令列: rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,0 命令列: rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1 命令列: rundll32.exe rnaui.dll,RnaDial [某个拨号连接的名称] 命令列: rundll32.exe rnaui.dll,RnaWizard 命令列: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0 命令列: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1 命令列: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2 命令列: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3 命令列: rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL FontsFolder 命令列: rundll32.exe shell32.dll,Control_RunDLL main.cpl @3 命令列: rundll32.exe shell32.dll,SHFormatDrive 命令列: rundll32.exe shell32.dll,Control_RunDLL joy.cpl,,0 命令列: rundll32.exe shell32.dll,Control_RunDLL joy.cpl,,1 命令列: rundll32.exe mshtml.dll,PrintHTML (HTML文档) 命令列: rundll32.exe shell32.dll,Control_RunDLL mlcfg32.cpl 命令列: rundll32.exe shell32.dll,Control_RunDLL main.cpl @0 命令列: rundll32.exe shell32.dll,Control_RunDLL main.cpl @1 命令列: rundll32.exe shell32.dll,Control_RunDLL main.cpl @1,,1 命令列: rundll32.exe shell32.dll,Control_RunDLL main.cpl @2 命令列: rundll32.exe shell32.dll,Control_RunDLL main.cpl @3 命令列: rundll32.exe shell32.dll,Control_RunDLL main.cpl @4 命令列: rundll32.exe shell32.dll,Control_RunDLL modem.cpl,,add 命令列: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,0 命令列: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,1 命令列: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,2 命令列: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,3 命令列: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,4 命令列: rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl @1 命令列: rundll32.exe shell32.dll,Control_RunDLL netcpl.cpl 命令列: rundll32.exe shell32.dll,Control_RunDLL odbccp32.cpl 命令列: rundll32.exe shell32.dll,OpenAs_RunDLL {drive:\path\filename} 命令列: rundll32.exe shell32.dll,Control_RunDLL password.cpl 命令列: rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl 命令列: rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder 命令列: rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,0 命令列: rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,1 命令列: rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,2 命令列: rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,3 命令列: rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,4 命令列: rundll32.exe desk.cpl,InstallScreenSaver [萤屏保护档案名] 命令列: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,0 命令列: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1 命令列: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,2 命令列: rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,3 命令列: rundll32.exe user.exe,restartwindows 命令列: rundll32.exe user.exe,exitwindows 命令列: rundll32.exe shell32.dll,Control_RunDLL telephon.cpl 命令列: rundll32.exe shell32.dll,Control_RunDLL themes.cpl |
请发表评论