1

i have this code for open explorer (by pressing button):

System.Diagnostics.Process.Start("IExplore.exe",@"C:\Help.html"); 

the problem is, if i press the button more than one time - the explorer will open a lot of shows

how to force the explorer to open only one time ?

thanks

6
  • 1
    have a look at this answer, may point you in the right direction stackoverflow.com/questions/187915/… Commented Oct 16, 2012 at 8:09
  • you can disable the button once you have clicked once .. Commented Oct 16, 2012 at 8:09
  • @MMK I was thinking that as well, but what happens if the user closes the browser and wants to re-launch from the OP's app? Commented Oct 16, 2012 at 8:10
  • Why don't you disable the button just after you click on it ? Commented Oct 16, 2012 at 8:10
  • 1
    Google it and you can find this: social.msdn.microsoft.com/forums/en-US/winforms/thread/… Commented Oct 16, 2012 at 8:10

6 Answers 6

2
if (Process.GetProcessesByName("iexplore").Length == 0) System.Diagnostics.Process.Start("IExplore.exe", @"C:\Help.html"); 
Sign up to request clarification or add additional context in comments.

Comments

1
  1. Disable button.
  2. Control clicking by a flag

ie ; on_btn_clkd()
{
if(!previouslyClickd)
{
(Click functionalities)
previouslyClicked = false;
}
else
return ;

Comments

0

Try to use this piece of code:

bool ProcessIsRunning(string process) { return (System.Diagnostics.Process.GetProcessesByName(process).Length != 0); } 

Usage:

if (!ProcessIsRunning("IExplore.exe")) System.Diagnostics.Process.Start("IExplore.exe",@"C:\Help.html"); 

Comments

0

You can do like this

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(); } 

Comments

0

Make use of ShDocVw.dll..
declare in instance of Internet explorer in your class

InternetExplorer wBrowser; 

and in your button click add

if (wBrowser==null) { wBrowser = new InternetExplorer(); wBrowser.Visible = true; wBrowser.Navigate(@"C:\Help.html"); } 

you need to add reference to ShDocVw which you will find in System32 in your project and import namespace using SHDocVw;

Comments

0

If sour default browser is IE just try this code:

System.Diagnostics.Process.Start(@"C:\Help.html"); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.