RSS Forums RSS

Get Url From IE

Please support our VB.NET advertiser: DiscountASP.NET – 3 Months Free on VB.NET Web Hosting
Reply
Posts: 42
Reputation: mansi sharma is an unknown quantity at this point 
Solved Threads: 0
mansi sharma mansi sharma is offline Offline
Light Poster

Get Url From IE

  #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 8:36 pm. Reason: Added code tags
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the VB.NET Forum
Views: 1988 | Replies: 0 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:18 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC