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);
}