using System . Runtime . InteropServices;
[ DllImport ( "User32.DLL" )]
public static extern int SendMessage( IntPtr hWnd, uint Msg, int wParam,
int lParam);
[ DllImport ( "User32.DLL" )]
public static extern IntPtr FindWindowEx( IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
public int IDM_ADDFAVORITES = 2261 ;
public uint WM_COMMAND = 0x0111 ;
private void Form1_Load( object sender , EventArgs e)
{
webBrowser1 . Navigate( "http://blog.sina.com.cn/zswang" );
}
private void button1_Click( object sender , EventArgs e)
{
IntPtr vHandle = webBrowser1 . Handle;
vHandle = FindWindowEx(vHandle, IntPtr . Zero, "Shell Embedding" , null );
vHandle = FindWindowEx(vHandle, IntPtr . Zero, "Shell DocObject View" , null );
vHandle = FindWindowEx(vHandle, IntPtr . Zero, "Internet Explorer_Server" , null );
SendMessage(vHandle, WM_COMMAND, IDM_ADDFAVORITES, ( int )Handle);
}