我现在有以下代码经由一个按钮发起数据网格内的WPF应用程序:在私人模式C#打开默认浏览器
private static string GetStandardBrowserPath()
{
string browserPath = string.Empty;
RegistryKey browserKey = null;
try
{
//Read default browser path from Win XP registry key
browserKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false);
//If browser path wasn't found, try Win Vista (and newer) registry key
if (browserKey == null)
{
browserKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http", false); ;
}
//If browser path was found, clean it
if (browserKey != null)
{
//Remove quotation marks
browserPath = (browserKey.GetValue(null) as string).ToLower().Replace("\"", "");
//Cut off optional parameters
if (!browserPath.EndsWith("exe"))
{
browserPath = browserPath.Substring(0, browserPath.LastIndexOf(".exe") + 4);
}
//Close registry key
browserKey.Close();
}
}
catch
{
//Return empty string, if no path was found
return string.Empty;
}
//Return default browsers path
return browserPath;
}
这如下返回浏览器路径:
"c:\\program files\\mozilla firefox\\firefox.exe -osint -url %1"
我想要做的是将另一个命令行添加到.exe的末尾以强制浏览器以私人模式打开,并且最终用户知道这会发生,但我不确定如何执行此操作。我想这样做的浏览器有:
- 谷歌浏览器
- 火狐狸
- 歌剧
- 互联网浏览
例如
"c:\\program files\\mozilla firefox\\firefox.exe -private -osint -url %1"
或
"c:\\program files (x86)\\google\\chrome\\application\\chrome.exe -incognito -- %1"
可能重复[如何在隐私浏览模式下打开链接](http://stackoverflow.com/questions/16148136/how-can-we-open-a-link-in-private-browsing-模式) –
[我的浏览器](http://lynx.browser.org)没有隐私浏览模式。 –
@ Dr.Stitch不是重复的,因为另一个问题是关于从网站开启私人模式,而这个问题是从本地桌面应用程序启动一个新的浏览器。 – NineBerry