Get Url From IE

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 75
Reputation: mansi sharma is an unknown quantity at this point 
Solved Threads: 0
mansi sharma mansi sharma is offline Offline
Junior Poster in Training

Get Url From IE

 
0
  #1
Sep 7th, 2008
  1. Imports mshtml
  2. Imports SHDocVw
  3. Imports Microsoft.Win32
  4. Imports System.Runtime.InteropServices
  5.  
  6.  
  7. Public Class Form1
  8.  
  9. Public Const BaseKey As String = "SOFTWARE\Microsoft\Internet Explorer\Extensions"
  10. Public Const SubKey As String = "{10954C80-4F0F-11d3-B17C-00C0DFE39736}"
  11.  
  12.  
  13. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  14. Dim reg As RegistryKey = Registry.LocalMachine
  15. Dim sk As RegistryKey = reg.OpenSubKey(BaseKey, True)
  16. sk = sk.CreateSubKey(SubKey)
  17.  
  18. sk.SetValue("ButtonText", "Button")
  19. sk.SetValue("CLSID", "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}")
  20. sk.SetValue("Default Visible", "Yes")
  21. sk.SetValue("Exec", "D:\Working\IEToolbarButtons\IEToolbarButtons\bin\Debug\IEToolbarButtons.exe")
  22. sk.SetValue("HotIcon", "C:\Windows\System\setup.ico")
  23. sk.SetValue("Icon", "C:\Windows\System\setup.ico")
  24. sk.Close()
  25. reg.Close()
  26.  
  27. End Sub
  28.  
  29. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  30. Dim browser As SHDocVw.InternetExplorer
  31. Dim myLocalLink As String
  32. Dim myDoc As mshtml.IHTMLDocument2
  33. Dim shellWindows As SHDocVw.ShellWindows = New SHDocVw.ShellWindows()
  34. Dim filename As String
  35.  
  36. For Each ie As SHDocVw.InternetExplorer In shellWindows
  37. filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower()
  38.  
  39. If filename = "iexplore" Then
  40. browser = ie
  41. myDoc = browser.Document
  42. myLocalLink = myDoc.url
  43. MessageBox.Show(myLocalLink)
  44. End If
  45. Next
  46.  
  47. End
  48.  
  49. End Sub
  50. End Class

mshtml-->Add reference microsoft.mshtml
SHDocVw--> Go to Add Reference-->Go to Broese tab-->C:--Windows--System32--shdocvw.dll

sk.SetValue("HotIcon", "C:\Windows\System\setup.ico")
C:\Windows\System\setup.ico--In place of it,Add any icon that has extension .ico,cz its not a valid ico file.

OUTPUT--
Open Two Sites are open google.com, daniweb.com.
Now open site yahoo.com. Click on button that is created with icon u added,when u clik on it.it shows as messageBox,
Fisrt google.com,daniweb.com & then yahoo.com

Cz all these sites are open.

I want that whether two sites are open google.com,daniweb.com,O/p Should be only yahoo.com
Last edited by cscgal; Sep 7th, 2008 at 9:36 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC