public static void Main(string[] args){
SearchGoogle("Test");
Console.ReadKey(true);
}
static void SearchGoogle(string t){
Process.Start("http://google.com/search?q=" + t);
}
有什么办法来隐藏浏览器,这样就不会弹出?C#,Process.Start隐藏?
public static void Main(string[] args){
SearchGoogle("Test");
Console.ReadKey(true);
}
static void SearchGoogle(string t){
Process.Start("http://google.com/search?q=" + t);
}
有什么办法来隐藏浏览器,这样就不会弹出?C#,Process.Start隐藏?
也许你正在寻找ProcessStartInfo.CreateNoWindow?
喜欢的东西:
ProcessStartInfo startInfo = new ProcessStartInfo("http://google.com/search?q=" + t);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(startInfo);
它不起作用,窗口是仍然可见 – GalDude33 2013-09-11 20:49:24
如果你想要的结果,而不是一个浏览器就可以使用WebClient类。
using (var client = new WebClient())
{
string html = client.DownloadString("http://google.com/search?q=" + "Test");
}
如果这是他所需要的,绝对是最好的解决方案。 – 2010-02-23 12:33:11
不知道为什么你需要这样做,但嘿,每个人都有一个理由。这里的ProcessStartInfo
代码完全符合你的需求:
ProcessStartInfo psi = new ProcessStartInfo(string.Format("http://google.com/search?q={0}",t));
psi.RedirectStandardOutput = false;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = true;
Process.Start(psi);
Noob先生:如果你不想让浏览器启动,那它应该在哪里显示网页? – bobbyalex 2010-02-23 11:46:25
如果你隐藏浏览器,那么你将如何显示结果? ;-)。需求令人兴奋吗? – Shoban 2010-02-23 11:46:49
它看起来像这就是你要找的... [用C#调用雅虎](http://developer.yahoo.com/dotnet/howto-rest_cs.html) – 2010-02-23 12:16:04