XXChester

Hello I am writting a little project to just learn the more hidden features of c#. Things like your systems current statis ect.

The thing I am stumped on and cannot seem to find anywhere how to do it is to obtain an instance of the Internet Explorer windows open on the current machine and then close them. If anyone has any idea how to do this or even the namespace to look it would be greatly appreciated.

I know it is the simple line "System.Diagnostics.Process.Start(www.hotmail.com);" to open a website but unfortuantely there is not the reverse of that like Process.Stop(...); sooo ya, any thoughts would be great.

Thank you in advance;

XXChester



Re: Internet Explorer Extension Development Closing IE in C#

IsshouFuuraibou

The reason is because there might be multiple processes with "iexplorer.exe". Do you end the first the last all of them

The way you get access to stopping/killing a process remotely from C# is to get an instance of the System.Diagnostics.Process and calling the instance methods. That way it knows which process to stop/terminate.

So look into how to get instances from current running processes (It's another static method of Process).





Re: Internet Explorer Extension Development Closing IE in C#

rtdev

This might not be exactly what you want. But if you know the MainWindowTitle, you could do something like the following:

// Start ieexplorer.exe and go to www.google.com.

System.Diagnostics.Process.Start("www.google.com");

// Waite 10 seconds.

System.Threading.Thread.Sleep(10000);

// Get all IEXPLORE processes.

System.Diagnostics.Process[] procs = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");

foreach (System.Diagnostics.Process proc in procs)

{

// Look for Google title.

if (proc.MainWindowTitle.IndexOf("Google") > -1)

proc.Kill(); // Close it down.

}







Re: Internet Explorer Extension Development Closing IE in C#

Ricky Wang

If you just need the function to close IE.

try the following

// Initialize the IE com object
SHDocVw.InternetExplorerClass ieCom = new SHDocVw.InternetExplorerClass();

// Show ie window or not
ieCom.Visible = true;

//Close the IE
base.ieCom.Quit();

Ricky.






Re: Internet Explorer Extension Development Closing IE in C#

rtdev

I like Ricky Wang's COM example to open and close IE. Also you have more control over IE.





Re: Internet Explorer Extension Development Closing IE in C#

Bortecin

Hello Chester,

I want to develop a plug-in for IE. Would you recommend me using C# for this purpose

Thanks in advance!

Regards