日期:2014-05-19  浏览次数:20900 次

[WinForm]axWebBrowser调用IE的添加到收藏夹对话框
这是伴水的方法
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);//我这里得到的是0
        vHandle   =   FindWindowEx(vHandle,   IntPtr.Zero,   "Shell   DocObject   View ",   null);//我这里得到的是0
        vHandle   =   FindWindowEx(vHandle,   IntPtr.Zero,   "Internet   Explorer_Server ",   null);//我这里得到的是0
        SendMessage(vHandle,   WM_COMMAND,   IDM_ADDFAVORITES,   (int)Handle);
}  

请麻烦解释下那3行代码的含义,就是那3个FindWindowEx

还有,就是我装的是IE7,会有区别不?

------解决方案--------------------
怎么没人回答
先用 AxImp c:\windows\system32\shdocvw.dll
产生二个文件AxShdocvw.dll和shdocvw.dll

在项目中引用这二个DLL

在cs中引用:
using SHDocVw;

代码:
ShellUIHelper helper = new ShellUIHelper();
object t = webBrowser1.Document.Title;//我这里是vs2005的WebBrowser控件
helper.AddFavorite(webBrowser1.Url.ToString(), ref t);//调用添加到收藏夹对话框
object o = null;
helper.ShowBrowserUI( "OrganizeFavorites ", ref o);//调用整理收藏夹对话框

------解决方案--------------------
关注,帮顶了
------解决方案--------------------
模式窗口必须调用DoAddToFavDlg()
参照 http://blog.csdn.net/lzmtw/archive/2007/03/15/1530746.aspx
------解决方案--------------------
mark
------解决方案--------------------
JF...