C# Enumerate IE

Posted on 2009-12-18
Last Modified: 2013-12-17
I'm trying to convert this VB code below to C# can someone help me? I'm trying to enumerate through IE windows find the specified URL and grab the specified elementy by id.
Private Sub CheckWindow()

        Dim ie As InternetExplorer

        Dim shellWins As New ShellWindows

        For Each ie In shellWins

            If ie.LocationURL = "" Then

                MsgBox("IE Found")


            End If


    End Sub

Open in new window

Question by:disrupt
    LVL 15

    Accepted Solution

    Hi find the below c# code....

    private void CheckWindow()
        InternetExplorer ie = default(InternetExplorer);
        ShellWindows shellWins = new ShellWindows();
        foreach (var ie in shellWins) {
            if (ie.LocationURL == "") {
                Interaction.MsgBox("IE Found");

    I used the link

    to convert...
    LVL 15

    Expert Comment

    I replaced            Ie.LocationURL == ""  - By StartsWith

    You need include reference to c:\Windows\System32\shdocvw.dll
    And                                          using SHDocVw;
    public void CheckWindow()
        ShellWindows windows = new ShellWindows();
        foreach (SHDocVw.InternetExplorer Ie in windows)
            if (Ie.LocationURL.StartsWith ( ""))
                MessageBox.Show("IE Found");

    Open in new window


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Now-a-days, indirectly, postal services have been replaced by email services. Yes, whenever we hear the word "email" a lot of people only think of gmail. Some people still think that email and gmail are one and the same thing :-). Let's see some …
    Several part series to implement Internet Explorer 11 Enterprise Mode
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
    How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now