How to Code-Build-Debug a BHO
Create BHO Register & Unregister Files
IE looks in the registry to find any plug-ins (BHOs) to load. You must register your BHO so IE can find it.
Create Register.bat:
-
Open a MS-DOS Command Prompt window.
-
Start Notepad: Notepad Register.bat
-
Enter the following on one line in Register.bat:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm
"c:\inetpub\wwwroot\BHO\BHO\bin\debug\BHO.dll" /codebase
You may need to locate regasm.exe and change the path accordingly.
Change the path to the location of your BHO project.
-
Start Notepad and create Unregister.bat.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm
"c:\inetpub\wwwroot\BHO\BHO\bin\Debug\BHO.dll" /unregister /codebase
Change the file paths as appropriate for your system.
Code-Build-Debug Cycle
-
Close all IE intstances and any windows created by IE such as View Source windows.
-
Open an Windows Command Prompt in Administrator-mode.
-
Click on Start Icon.
-
Go to All Programs\Accessories and find Command Prompt.
-
Go Right-click on Command Prompt.
-
Click on "Run as Administrator".
-
Enter Unregister.bat.
This will unregister any previous version of your BHO.
-
Enter Register.Bat.
-
Start IE.
-
Do not start IE from the bottom menu!
-
Click on Start icon.
-
Find & click on Internet Explorer.
Create a Separate Class Library
Debugging an IE Browser Helper Object (BHO) is challenging.
To improve your development process I suggest:
-
Create a separate class library to hold your main code modules.
-
Test your classes using an open source tests tools like MbUnit and Gallio.
-
Code your BHO to reference classes in your class library.
How to Display Debug Messages - Simple
string Message;
Message = String.Format("Counter = {0}", Counter);
System.Windows.Forms.MessageBox.Show(Message);
How to Auto-Click A Button
How to Select Radio Button Options
How to Set a Checkbox
InputObj = (HTMLInputElement)Element1Obj;
InputObj.value = FieldObj.Value;
if (FieldObj.Value == "Y")
{
InputObj.setAttribute("checked", "true");
}
How to Set Text in Text Boxes
How to Parse or Screen-Scrape Page Information