我有这个打开资源管理器的代码(通过按下按钮):
System.Diagnostics.Process.Start("IExplore.exe",@"C:\Help.html");
问题是,如果我多次按下按钮 - 资源管理器将打开很多节目
如何强制资源管理器只打开一次?
谢谢
if (Process.GetProcessesByName("iexplore").Length == 0)
System.Diagnostics.Process.Start("IExplore.exe", @"C:\Help.html");
IE ; on_btn_clkd()
{
if(!previouslyClickd)
{
(点击功能)
previousClicked = false;
}
否则
返回;
在您的班级中使用ShDocVw.dll
..
在 Internet Explorer 的实例中声明
InternetExplorer wBrowser;
并在您的按钮中单击添加
if (wBrowser==null)
{
wBrowser = new InternetExplorer();
wBrowser.Visible = true;
wBrowser.Navigate(@"C:\Help.html");
}
您需要添加在项目中ShDocVw
找到的引用System32
并导入命名空间using SHDocVw;
尝试使用这段代码:
bool ProcessIsRunning(string process)
{
return (System.Diagnostics.Process.GetProcessesByName(process).Length != 0);
}
用法:
if (!ProcessIsRunning("IExplore.exe"))
System.Diagnostics.Process.Start("IExplore.exe",@"C:\Help.html");
如果酸的默认浏览器IE
只是试试这个代码:
System.Diagnostics.Process.Start(@"C:\Help.html");
你可以这样做
private void Form1_Load(object sender, EventArgs e)
{
IeProcess = new Process();
startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
}
private void buttonStackoverflow_Click(object sender, EventArgs e)
{
startInfo.FileName = "www.Stackoverflow.com";
IeProcess.StartInfo = startInfo;
IeProcess.Start();
}
private void buttongoogle_Click(object sender, EventArgs e)
{
startInfo.FileName = "www.google.com";
IeProcess.Start();
}