GETTING A LIST OF ACTIVE INTERNET EXPLORERS WINDOW IN C#
Have you ever wanted to write your own pop-up blocker?
Ah. Me neither. There are too many free ones available today (and the one built into Internet Explorer).
If you did however want to find out all of the running instances of Internet Explorer and their current URLs however, it's easy to do in .NET (C# in this example):
Include a reference to the COM library Microsoft Internet Controls and to the .NET assembly Microsoft.mshtml.
Add three using statements:
using SHDocVw;
using mshtml;
using System.Runtime.InteropServices;
Add the following code (in a button click, or in your program's main function for example):
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
foreach ( object window in shellWindows )
{
SHDocVw.InternetExplorer IEInstance = window as SHDocVw.InternetExplorer;
if (IEInstance != null)
{
HTMLDocument doc = IEInstance.Document as HTMLDocument;
if (doc != null)
{
Console.WriteLine(doc.url);
}
}
}
Done.
As you might guess, this does not work with other browsers.
soum-net
Thursday, January 27, 2005
Tuesday, January 18, 2005
ASCII TO CHAR
Q)
Method or any approach to convert an integer value to
its ascii?
Just for example i have 65. how will it be converted to 'A' in C#.
A 1)
byte [] bites = {65};
char [] chars = new char[Encoding.ASCII.GetCharCount(bites,0,1)];
Encoding.ASCII.GetChars(bites,0,1,chars,0);
A 2) (easy one)
using Microsoft.VisualBasic;
Microsoft.VisualBasic.Strings.Chr(65)
Q)
Method or any approach to convert an integer value to
its ascii?
Just for example i have 65. how will it be converted to 'A' in C#.
A 1)
byte [] bites = {65};
char [] chars = new char[Encoding.ASCII.GetCharCount(bites,0,1)];
Encoding.ASCII.GetChars(bites,0,1,chars,0);
A 2) (easy one)
using Microsoft.VisualBasic;
Microsoft.VisualBasic.Strings.Chr(65)
