[英]C#, Process.Start hide?
public static void Main(string[] args){
SearchGoogle("Test");
Console.ReadKey(true);
}
static void SearchGoogle(string t){
Process.Start("http://google.com/search?q=" + t);
}
有没有办法隐藏浏览器,所以它不会弹出?
就像是:
ProcessStartInfo startInfo = new ProcessStartInfo("http://google.com/search?q=" + t);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(startInfo);
也许您正在寻找ProcessStartInfo.CreateNoWindow ?
如果您想要结果而不是浏览器,则可以使用WebClient类。
using (var client = new WebClient())
{
string html = client.DownloadString("http://google.com/search?q=" + "Test");
}
不知道为什么你需要这样做,但是,嘿,每个人都有理由。 这是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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.