0

I want to start internet explorer if there is no instance running. I'm using this code. but it returns me wrong iExplorerInstances.Count count. How i can get actual ExplorerInstances

    SHDocVw.ShellWindows iExplorerInstances = new SHDocVw.ShellWindows();
       if (iExplorerInstances.Count > 0)
           {
            IEnumerator enumerator = iExplorerInstances.GetEnumerator();
            enumerator.MoveNext();
            InternetExplorer iExplorer = (InternetExplorer)enumerator.Current;
            iExplorer.Navigate(url, 0x800);
            }
        else
           {
            //Start new process..
            }
navi
  • 63
  • 2
  • 10

1 Answers1

0

Maybe .NET API will help

Process[] processlist = Process.GetProcesses();

foreach(Process process in processlist){
  if (process.MainModule.FileName.EndsWith("iexplore.exe"))
       return true;
}

return false;

Pleas see also this approach (using WMIC): https://stackoverflow.com/a/5497319/1779504

Community
  • 1
  • 1
csharpfolk
  • 4,124
  • 25
  • 31