技术文章 > C#操作IE收藏夹

C#操作IE收藏夹

2018-08-18 23:46

文档管理软件,文档管理系统,知识管理系统,档案管理系统的技术资料:

C#对IE收藏夹的操作

主要是用命令调用: 整理收藏夹 打开收藏夹所在目录 添加到收藏夹

[DllImport(“shdocvw.dll“)]
public static extern int DoOrganizeFavDlg(IntPtr hWnd, string pchar);
/// <summary>
/// 整理收藏夹
/// </summary>
/// <param name=“sender“></param>
/// <param name=“e“></param>
private void 管理收藏夹ToolStripMenuItem_Click(object sender, EventArgs e)
{
DoOrganizeFavDlg(this.Handle, null);
}


/// <summary>
/// 打开收藏夹所在目录
/// </summary>
/// <param name=“sender“></param>
/// <param name=“e“></param>
private void tsm_opensqml_Click(object sender, EventArgs e)
{
string favorfolder = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
System.Diagnostics.Process.Start(“explorer.exe“, favorfolder);
}

[DllImport(“User32.DLL “)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam,int lParam);
public int IDM_ADDFAVORITES = 2261;
public uint WM_COMMAND = 0x0111;

// 添加到收藏夹
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
csExWB.cEXWB cw = tabControl1.SelectedTab.Controls[0] as csExWB.cEXWB;

IntPtr vHandle = cw.IEServerHwnd;

SendMessage(vHandle, WM_COMMAND, IDM_ADDFAVORITES, (int)Handle);

}