public static void Main(string[] args){
SearchGoogle("Test");
Console.ReadKey(true);
}
static void SearchGoogle开发者_运维百科(string t){
Process.Start("http://google.com/search?q=" + t);
}
Is there any way to hide the browser, so it won't pop up??
Something like:
ProcessStartInfo startInfo = new ProcessStartInfo("http://google.com/search?q=" + t);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(startInfo);
Perhaps you are looking for ProcessStartInfo.CreateNoWindow ?
If you want the results instead of a Browser you can use the WebClient class.
using (var client = new WebClient())
{
string html = client.DownloadString("http://google.com/search?q=" + "Test");
}
Not sure why you'd need to do this, but hey, everyone has a reason. Here's ProcessStartInfo
code that does exactly what you need:
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);
精彩评论