2009-06-13 49 views
-1

我正在使用c#的Windows應用程序。我想從瀏覽器中檢索URL。但我無法做到這一點。如何從瀏覽器使用c檢索URL#

private void WebListLoad() 
{ 
    ListViewItem lvi; 
    Process[] prs = Process.GetProcessesByName("firefox"); 
    try 
    { 

    //int handle = int.Parse(Console.ReadLine(), NumberStyles.HexNumber); 
    //int txtLength = SendMessage(handle, WM_GETTEXTLENGTH, 0, 0); 
    //StringBuilder sb = new StringBuilder(txtLength + 1); 
    //SendMessage(handle, WM_GETTEXT, sb.Capacity, sb); 


     foreach (Process proces in prs) 
     { 
      if (proces.MainWindowTitle.Length > 0) 
      { 
       lvi = listView2.Items.Add(System.Environment.UserName); 
       lvi.SubItems.Add(""); 
       lvi.SubItems.Add(proces.MainWindowTitle.ToString()); 
       lvi.SubItems.Add(proces.StartTime.ToString()); 
      } 
     } 
    } 
    catch 
    { 
    } 
} 

回答

0
string WebText = ""; 
foreach (InternetExplorer ie in new ShellWindowsClass()) 
{ 
    filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower(); 
    if (filename == "iexplore") 
    Url = ie.LocationURL.ToString(); 
}