在网上找有VB VC 就是没C#的
C#能实现吗?
找到了一个类可能有关,但不知道如何用!
请大侠给个完整的解决方法。
参考资料
// Class for deleting the cache.
    class DeleteCache
    {
        // For PInvoke: Contains information about an entry in the Internet cache
        [StructLayout(LayoutKind.Explicit, Size = 80)]
        public struct INTERNET_CACHE_ENTRY_INFOA
        {
            [FieldOffset(0)]
            public uint dwStructSize;
            [FieldOffset(4)]
            public IntPtr lpszSourceUrlName;
            [FieldOffset(8)]
            public IntPtr lpszLocalFileName;
            [FieldOffset(12)]
            public uint CacheEntryType;
            [FieldOffset(16)]
            public uint dwUseCount;
            [FieldOffset(20)]
            public uint dwHitRate;
            [FieldOffset(24)]
            public uint dwSizeLow;
            [FieldOffset(28)]
            public uint dwSizeHigh;
            [FieldOffset(32)]
            public FILETIME LastModifiedTime;
            [FieldOffset(40)]
            public FILETIME ExpireTime;
            [FieldOffset(48)]
            public FILETIME LastAccessTime;
            [FieldOffset(56)]
            public FILETIME LastSyncTime;
            [FieldOffset(64)]
            public IntPtr lpHeaderInfo;
            [FieldOffset(68)]
            public uint dwHeaderInfoSize;
            [FieldOffset(72)]
            public IntPtr lpszFileExtension;
            [FieldOffset(76)]
            public uint dwReserved;
            [FieldOffset(76)]
            public uint dwExemptDelta;
        }        // For PInvoke: Initiates the enumeration of the cache groups in the Internet cache
        [DllImport(@"wininet",
            SetLastError = true,
            CharSet = CharSet.Auto,
            EntryPoint = "FindFirstUrlCacheGroup",
            CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr FindFirstUrlCacheGroup(
            int dwFlags,
            int dwFilter,
            IntPtr lpSearchCondition,
            int dwSearchCondition,
            ref long lpGroupId,
            IntPtr lpReserved);        // For PInvoke: Retrieves the next cache group in a cache group enumeration
        [DllImport(@"wininet",
            SetLastError = true,
            CharSet = CharSet.Auto,
            EntryPoint = "FindNextUrlCacheGroup",
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool FindNextUrlCacheGroup(
            IntPtr hFind,
            ref long lpGroupId,
            IntPtr lpReserved);        // For PInvoke: Releases the specified GROUPID and any associated state in the cache index file
        [DllImport(@"wininet",
            SetLastError = true,
            CharSet = CharSet.Auto,
            EntryPoint = "DeleteUrlCacheGroup",
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool DeleteUrlCacheGroup(
            long GroupId,
            int dwFlags,
            IntPtr lpReserved);        // For PInvoke: Begins the enumeration of the Internet cache
        [DllImport(@"wininet",
            SetLastError = true,
            CharSet = CharSet.Auto,
            EntryPoint = "FindFirstUrlCacheEntryA",
            CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr FindFirstUrlCacheEntry(
            [MarshalAs(UnmanagedType.LPTStr)] string lpszUrlSearchPattern,
            IntPtr lpFirstCacheEntryInfo,
            ref int lpdwFirstCacheEntryInfoBufferSize);        // For PInvoke: Retrieves the next entry in the Internet cache
        [DllImport(@"wininet",
            SetLastError = true,
            CharSet = CharSet.Auto,
            EntryPoint = "FindNextUrlCacheEntryA",
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool FindNextUrlCacheEntry(
            IntPtr hFind,
            IntPtr lpNextCacheEntryInfo,
            ref int lpdwNextCacheEntryInfoBufferSize);        // For PInvoke: Removes the file that is associated with the source name from the cache, if the file exists
        [DllImport(@"wininet",
            SetLastError = true,
            CharSet = CharSet.Auto,
            EntryPoint = "DeleteUrlCacheEntryA",
            CallingConvention = CallingConvention.StdCall)]
        public static extern bool DeleteUrlCacheEntry(
            IntPtr lpszUrlName);        //http://support.microsoft.com/kb/326201/en-us
    }

解决方案 »

  1.   

    如何清空 Temporary Internet Files 里临时文件!就象IE里的
    删除COOKIE
    删除文件
      

  2.   

    参考如下代码:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;namespace IEHistory
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                IUrlHistoryStg2 vUrlHistoryStg2 = (IUrlHistoryStg2)new UrlHistory();
                vUrlHistoryStg2.ClearHistory();//清除历史
            }
        }    struct STATURL
        {
            public static uint SIZEOF_STATURL =
                (uint)Marshal.SizeOf(typeof(STATURL));        public uint cbSize;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pwcsUrl;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pwcsTitle;
            public FILETIME ftLastVisited,
                ftLastUpdated,
                ftExpires;
            public uint dwFlags;
        }    [ComImport, Guid("3C374A42-BAE4-11CF-BF7D-00AA006946EE"), 
            InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        interface IEnumSTATURL
        {
            [PreserveSig]
            uint Next(uint celt, out STATURL rgelt, out uint pceltFetched);
            void Skip(uint celt);
            void Reset();
            void Clone(out IEnumSTATURL ppenum);
            void SetFilter(
                [MarshalAs(UnmanagedType.LPWStr)] string poszFilter,
                uint dwFlags);
        }    [ComImport, Guid("AFA0DC11-C313-11d0-831A-00C04FD5AE38"),
            InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        interface IUrlHistoryStg2
        {
            #region IUrlHistoryStg methods
            void AddUrl(
                [MarshalAs(UnmanagedType.LPWStr)] string pocsUrl,
                [MarshalAs(UnmanagedType.LPWStr)] string pocsTitle,
                uint dwFlags);        void DeleteUrl(
                [MarshalAs(UnmanagedType.LPWStr)] string pocsUrl,
                uint dwFlags);        void QueryUrl(
                [MarshalAs(UnmanagedType.LPWStr)] string pocsUrl,
                uint dwFlags,
                ref STATURL lpSTATURL);        void BindToObject(
                [MarshalAs(UnmanagedType.LPWStr)] string pocsUrl,
                ref Guid riid,
                [MarshalAs(UnmanagedType.IUnknown)] out object ppvOut);        IEnumSTATURL EnumUrls();
            #endregion        void AddUrlAndNotify(
                [MarshalAs(UnmanagedType.LPWStr)] string pocsUrl,
                [MarshalAs(UnmanagedType.LPWStr)] string pocsTitle,
                uint dwFlags,
                [MarshalAs(UnmanagedType.Bool)] bool fWriteHistory,
                [MarshalAs(UnmanagedType.IUnknown)] object /*IOleCommandTarget*/
                poctNotify,
                [MarshalAs(UnmanagedType.IUnknown)] object punkISFolder);        void ClearHistory();
        }    [ComImport, Guid("3C374A40-BAE4-11CF-BF7D-00AA006946EE")]
        class UrlHistory /* : IUrlHistoryStg[2] */ { }
    }
      

  3.   

    其实这个效果很简单啊,为什么这么麻烦呢?循环
    清楚COOKIE   打开WEB
      

  4.   

            
    我记得有COM接口可以直接调用删除IE临时文件夹的对话框,但一时找不到,只能模拟了[DllImport("User32.dll")]
            private static extern int FindWindow(string strClassName, string strWindowName);
            [DllImport("User32.dll")]
            private static extern int FindWindowEx(int hwndParent, int hwndChildAfter, string strClassName, string strWindowName);
            [DllImport("User32.dll ")]
            private static extern IntPtr PostMessage(int hwnd, int wMsg, int wParam, string lParam); 
            private const int WM_CLICK = 0x00F5;           private void button1_Click(object sender, EventArgs e)
            {
                System.Diagnostics.Process.Start("InetCpl.cpl");
                System.Threading.Thread.Sleep(300);
                int h1 = 0, h2 = 0, h3=0,h4=0,h5=0;
                h1 = FindWindow(null, "Internet 属性"); 
                if (h1 != 0)
                {
                    h2 = FindWindowEx(h1, 0, null, "常规");
                    if (h2 != 0)
                    {
                        h3 = FindWindowEx(h2, 0, "Button", "删除文件(&F)..."); 
                        if (h3 != 0)
                        {
                            PostMessage(h3, WM_CLICK, 0, null);
                            System.Threading.Thread.Sleep(100);
                            h4 = FindWindow(null, "删除文件");
                            System.Threading.Thread.Sleep(300);
                            if (h4 != 0)
                            {
                                h5 = FindWindowEx(h4, 0, null, "确定");
                                if (h5 != 0)
                                {
                                    PostMessage(h5, WM_CLICK, 0, null);
                                }
                            }
                        }
                    }
                }
            }