Principle: http://hi.baidu.com/wu1987116/blog/item/8352896056ea254deaf8f83e.html
Function in this example: When ie accesses the Baidu: content, execute ceshi.exeProgramIn the program, the content is used as a search
Content, execute Baidu search
Steps:
Create a Windows Application in vs2005
Static void main () in the program. CS File ()
Add to MethodCode:
Static void main ()
{
Application. enablevisualstyles ();
Application. setcompatibletextrenderingdefault (false );
If (system. environment. getcommandlineargs (). length> 1) // If any startup parameter exists
{
String strcmd = system. environment. getcommandlineargs () [1]. tolower ();
String startcmd = "http://www.baidu.com/s? WD = "+ strcmd. Replace (" Baidu :","");
System. Diagnostics. process. Start (startcmd );
}
Else
{
MessageBox. Show ("parameter error! "," Prompt ");
}
}
Generate EXE file
Import the following registry information:
Windows Registry Editor Version 5.00
[Hkey_classes_root \ Baidu]
@ = ""
"URL protocol" = ""
[Hkey_classes_root \ Baidu \ shell]
[Hkey_classes_root \ Baidu \ shell \ open]
[Hkey_classes_root \ Baidu \ shell \ open \ command]
@ = "D: \ ceshi.exe % 1"
"D: \ ceshi.exe % 1" is the generated program path,
what this registry implements is when the browser (or other) encounters a Baidu :... Ceshi.exe is automatically called, and Baidu :... The address is passed as a parameter to ceshi.exe, and ceshi.exe is used to determine the input parameter format and perform the operation.