代码是参考网上的,获取Input的name 但是注册成功,点网页按钮的时候怎么不起作用
大牛帮我看看
[ComVisible(true),
Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),
ClassInterface(ClassInterfaceType.None)
]
public class BHO:IObjectWiteSite
{
SHDocVw.WebBrowser webBrowser;
HTMLDocument htmlDocument;
public void OnDocumentComplete(object disp,ref object url)
{
try
{
htmlDocument = (HTMLDocument)webBrowser.Document;
foreach (IHTMLInputElement tempElement in htmlDocument.getElementsByTagName("INPUT"))
{
MessageBox.Show(tempElement.name!=null?tempElement.name:"it sucks,no name,try id"+((IHTMLElement)tempElement).id);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
public int SetSite([MarshalAs(UnmanagedType.IUnknown)] Object site)
{
if (site != null)
{
webBrowser = (SHDocVw.WebBrowser)site;
webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
}
else
{
webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
webBrowser = null;
}
return 0;
}
public int GetSite(ref Guid guid, out IntPtr ppvSite)
{
IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
Marshal.Release(punk);
return 0;
}
public static string BHOKEYNAME = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects";
[ComRegisterFunction]
public static void RegisterBHO(Type type)
{
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(BHOKEYNAME,true);
if (registryKey == null)
registryKey = Registry.LocalMachine.CreateSubKey(BHOKEYNAME);
string guid = type.GUID.ToString("B");
RegistryKey outKey = registryKey.OpenSubKey(guid);
if (outKey == null)
outKey = registryKey.CreateSubKey(guid);
outKey.SetValue("Alright", 1);
registryKey.Close();
outKey.Close();
}
}
[课程]Android-CTF解题方法汇总!