删除IE的临时文件 100分结贴迅速

hmgujie 2008-07-10 04:23:43
C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files 怎么删除这个文件下的所有文件 比如像Cookie:administrator@www.sogou.com/这样的文件 普通删除不了 高手指点下
...全文
366 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
liyoubaidu 2009-07-26
  • 打赏
  • 举报
回复
up
jinjazz 2008-07-10
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 hyruur 的回复:]
只有调用API函数删,最好的方法将硬盘格式化
[/Quote]
治牙疼最好的办法是所有牙都敲了,脚上被蚊子咬了最好的办法是截肢...
cychris 2008-07-10
  • 打赏
  • 举报
回复
学习.....
我很懒 2008-07-10
  • 打赏
  • 举报
回复
只有调用API函数删,最好的方法将硬盘格式化
格拉 2008-07-10
  • 打赏
  • 举报
回复
学习!
Code従業員 2008-07-10
  • 打赏
  • 举报
回复
学习,顶
yagebu1983 2008-07-10
  • 打赏
  • 举报
回复
学习ericzhangbo1982111!!!!
这么多的代码啊!!!
UP!!!
ericzhangbo1982111 2008-07-10
  • 打赏
  • 举报
回复
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.IO;

namespace UrlHistoryLibrary
{
/// <summary>
/// The class that wraps the C# equivalence of the IURLHistory Interface (in the file "urlhist.cs")
/// </summary>
public class UrlHistoryWrapperClass
{

UrlHistoryClass urlHistory;
IUrlHistoryStg2 obj;

/// <summary>
/// Default constructor for UrlHistoryWrapperClass
/// </summary>
public UrlHistoryWrapperClass()
{

urlHistory = new UrlHistoryClass();
obj = (IUrlHistoryStg2)urlHistory;
SHDocVw.ShellUIHelper h=new SHDocVw.ShellUIHelper();
string o="aaa";
object x=(object)o;
h.AddFavorite("http://www.sina.com", ref x);





}

/// <summary>
/// Clean up any resources being used.
/// </summary>
public void Dispose()
{
Marshal.ReleaseComObject(obj);
urlHistory = null;
}

/// <summary>
/// Places the specified URL into the history. If the URL does not exist in the history, an entry is created in the history. If the URL does exist in the history, it is overwritten.
/// </summary>
/// <param name="pocsUrl">the string of the URL to place in the history</param>
/// <param name="pocsTitle">the string of the title associated with that URL</param>
/// <param name="dwFlags">the flag which indicate where a URL is placed in the history.
/// <example><c>ADDURL_FLAG.ADDURL_ADDTOHISTORYANDCACHE</c></example>
/// </param>
public void AddHistoryEntry(string pocsUrl, string pocsTitle, ADDURL_FLAG dwFlags)
{
obj.AddUrl(pocsUrl, pocsTitle, dwFlags);

}

/// <summary>
/// Deletes all instances of the specified URL from the history. does not work!
/// </summary>
/// <param name="pocsUrl">the string of the URL to delete.</param>
/// <param name="dwFlags"><c>dwFlags = 0</c></param>
public void DeleteHistoryEntry(string pocsUrl, int dwFlags)
{

try
{
obj.DeleteUrl(pocsUrl, dwFlags);
}
catch (Exception ex)
{

}


}


/// <summary>
///Queries the history and reports whether the URL passed as the pocsUrl parameter has been visited by the current user.
/// </summary>
/// <param name="pocsUrl">the string of the URL to querythe string of the URL to query.</param>
/// <param name="dwFlags">STATURL_QUERYFLAGS Enumeration
/// <example><c>STATURL_QUERYFLAGS.STATURL_QUERYFLAG_TOPLEVEL</c></example></param>
/// <returns>Returns STATURL structure that received additional URL history information. If the returned STATURL's pwcsUrl is not null, Queried URL has been visited by the current user.
/// </returns>
public STATURL QueryUrl(string pocsUrl, STATURL_QUERYFLAGS dwFlags)
{

STATURL lpSTATURL = new STATURL();

try
{
//In this case, queried URL has been visited by the current user.
obj.QueryUrl(pocsUrl, dwFlags, ref lpSTATURL);
//lpSTATURL.pwcsUrl is NOT null;
return lpSTATURL;
}
catch (FileNotFoundException)
{
//Queried URL has not been visited by the current user.
//lpSTATURL.pwcsUrl is set to null;
return lpSTATURL;
}

}

/// <summary>
/// Delete all the history except today's history, and Temporary Internet Files.
/// </summary>
public void ClearHistory()
{

obj.ClearHistory();

}



/// <summary>
/// Create an enumerator that can iterate through the history cache. UrlHistoryWrapperClass does not implement IEnumerable interface
/// </summary>
/// <returns>Returns STATURLEnumerator object that can iterate through the history cache.</returns>
public STATURLEnumerator GetEnumerator()
{
return new STATURLEnumerator((IEnumSTATURL)obj.EnumUrls);
}

/// <summary>
/// The inner class that can iterate through the history cache. STATURLEnumerator does not implement IEnumerator interface.
/// The items in the history cache changes often, and enumerator needs to reflect the data as it existed at a specific point in time.
/// </summary>
public class STATURLEnumerator
{
IEnumSTATURL enumrator;
int index;
STATURL staturl;

/// <summary>
/// Constructor for <c>STATURLEnumerator</c> that accepts IEnumSTATURL object that represents the <c>IEnumSTATURL</c> COM Interface.
/// </summary>
/// <param name="enumrator">the <c>IEnumSTATURL</c> COM Interface</param>
public STATURLEnumerator(IEnumSTATURL enumrator)
{
this.enumrator = enumrator;
}
//Advances the enumerator to the next item of the url history cache.
/// <summary>
/// Advances the enumerator to the next item of the url history cache.
/// </summary>
/// <returns>true if the enumerator was successfully advanced to the next element;
/// false if the enumerator has passed the end of the url history cache.
/// </returns>
public bool MoveNext()
{
staturl = new STATURL();
try
{
enumrator.Next(1, ref staturl, out index);
}
catch
{ }
if (index == 0)
return false;
else
return true;
}

/// <summary>
/// Gets the current item in the url history cache.
/// </summary>
public STATURL Current
{
get
{
return staturl;
}
}

/// <summary>
/// Skips a specified number of Call objects in the enumeration sequence. does not work!
/// </summary>
/// <param name="celt"></param>
public void Skip(int celt)
{
enumrator.Skip(celt);
}
/// <summary>
/// Resets the enumerator interface so that it begins enumerating at the beginning of the history.
/// </summary>
public void Reset()
{
enumrator.Reset();
}


public STATURLEnumerator Clone()
{
IEnumSTATURL ppenum;
enumrator.Clone(out ppenum);
return new STATURLEnumerator(ppenum);

}

public void SetFilter(string poszFilter, STATURLFLAGS dwFlags)
{
enumrator.SetFilter(poszFilter, dwFlags);
}

public void GetUrlHistory(IList list)
{

while (true)
{
staturl = new STATURL();
enumrator.Next(1, ref staturl, out index);
if (index == 0)
break;
list.Add(staturl);

}
enumrator.Reset();

}

}

}

}
ericzhangbo1982111 2008-07-10
  • 打赏
  • 举报
回复
using System;
using System.Runtime.InteropServices;
using System.Collections;

namespace UrlHistoryLibrary
{
public struct FILETIME
{
// Summary:
// Specifies the high 32 bits of the FILETIME.
public int dwHighDateTime;
//
// Summary:
// Specifies the low 32 bits of the FILETIME.
public int dwLowDateTime;
}

/// <summary>
/// Used by QueryUrl method
/// </summary>
public enum STATURL_QUERYFLAGS : uint
{
/// <summary>
/// The specified URL is in the content cache.
/// </summary>
STATURL_QUERYFLAG_ISCACHED = 0x00010000,
/// <summary>
/// Space for the URL is not allocated when querying for STATURL.
/// </summary>
STATURL_QUERYFLAG_NOURL = 0x00020000,

STATURL_QUERYFLAG_NOTITLE = 0x00040000,

STATURL_QUERYFLAG_TOPLEVEL = 0x00080000,

}
/// <summary>
/// Flag on the dwFlags parameter of the STATURL structure, used by the SetFilter method.
/// </summary>
public enum STATURLFLAGS : uint
{
/// <summary>
/// Flag on the dwFlags parameter of the STATURL structure indicating that the item is in the cache.
/// </summary>
STATURLFLAG_ISCACHED = 0x00000001,
/// <summary>
/// Flag on the dwFlags parameter of the STATURL structure indicating that the item is a top-level item.
/// </summary>
STATURLFLAG_ISTOPLEVEL = 0x00000002,
}
/// <summary>
/// Used bu the AddHistoryEntry method.
/// </summary>
public enum ADDURL_FLAG : uint
{
/// <summary>
/// Write to both the visited links and the dated containers.
/// </summary>
ADDURL_ADDTOHISTORYANDCACHE = 0,
/// <summary>
/// Write to only the visited links container.
/// </summary>
ADDURL_ADDTOCACHE = 1
}


/// <summary>
/// The structure that contains statistics about a URL.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct STATURL
{
/// <summary>
/// Struct size
/// </summary>
public int cbSize;
/// <summary>
/// URL
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pwcsUrl;
/// <summary>
/// Page title
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string pwcsTitle;
/// <summary>
/// Last visited date (UTC)
/// </summary>
public FILETIME ftLastVisited;
/// <summary>
/// Last updated date (UTC)
/// </summary>
public FILETIME ftLastUpdated;
/// <summary>
/// The expiry date of the Web page's content (UTC)
/// </summary>
public FILETIME ftExpires;
/// <summary>
/// Flags. STATURLFLAGS Enumaration.
/// </summary>
public STATURLFLAGS dwFlags;

/// <summary>
/// sets a column header in the DataGrid control. This property is not needed if you do not use it.
/// </summary>
public string URL
{
get { return pwcsUrl; }
}
/// <summary>
/// sets a column header in the DataGrid control. This property is not needed if you do not use it.
/// </summary>
public string Title
{
get
{
if (pwcsUrl.StartsWith("file:"))
return Win32api.CannonializeURL(pwcsUrl, Win32api.shlwapi_URL.URL_UNESCAPE).Substring(8).Replace('/', '\\');
else
return pwcsTitle;
}
}
/// <summary>
/// sets a column header in the DataGrid control. This property is not needed if you do not use it.
/// </summary>
public DateTime LastVisited
{
get
{
return Win32api.FileTimeToDateTime(ftLastVisited).ToLocalTime();
}
}
/// <summary>
/// sets a column header in the DataGrid control. This property is not needed if you do not use it.
/// </summary>
public DateTime LastUpdated
{
get
{
return Win32api.FileTimeToDateTime(ftLastUpdated).ToLocalTime();
}
}
/// <summary>
/// sets a column header in the DataGrid control. This property is not needed if you do not use it.
/// </summary>
public DateTime Expires
{
get
{
try
{
return Win32api.FileTimeToDateTime(ftExpires).ToLocalTime();
}
catch (Exception)
{
return DateTime.Now;
}
}
}

}

[StructLayout(LayoutKind.Sequential)]
public struct UUID
{
public int Data1;
public short Data2;
public short Data3;
public byte[] Data4;
}

//Enumerates the cached URLs
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("3C374A42-BAE4-11CF-BF7D-00AA006946EE")]
public interface IEnumSTATURL
{
void Next(int celt, ref STATURL rgelt, out int pceltFetched); //Returns the next \"celt\" URLS from the cache
void Skip(int celt); //Skips the next \"celt\" URLS from the cache. doed not work.
void Reset(); //Resets the enumeration
void Clone(out IEnumSTATURL ppenum); //Clones this object
void SetFilter([MarshalAs(UnmanagedType.LPWStr)] string poszFilter, STATURLFLAGS dwFlags); //Sets the enumeration filter

}


[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("3C374A41-BAE4-11CF-BF7D-00AA006946EE")]
public interface IUrlHistoryStg
{
void AddUrl(string pocsUrl, string pocsTitle, ADDURL_FLAG dwFlags); //Adds a new history entry
void DeleteUrl(string pocsUrl, int dwFlags); //Deletes an entry by its URL. does not work!
void QueryUrl([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl, STATURL_QUERYFLAGS dwFlags, ref STATURL lpSTATURL); //Returns a STATURL for a given URL
void BindToObject([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut); //Binds to an object. does not work!
object EnumUrls { [return: MarshalAs(UnmanagedType.IUnknown)] get;} //Returns an enumerator for URLs


}

[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("AFA0DC11-C313-11D0-831A-00C04FD5AE38")]
public interface IUrlHistoryStg2 : IUrlHistoryStg
{
new void AddUrl(string pocsUrl, string pocsTitle, ADDURL_FLAG dwFlags); //Adds a new history entry
new void DeleteUrl(string pocsUrl, int dwFlags); //Deletes an entry by its URL. does not work!
new void QueryUrl([MarshalAs(UnmanagedType.LPWStr)] string pocsUrl, STATURL_QUERYFLAGS dwFlags, ref STATURL lpSTATURL); //Returns a STATURL for a given URL
new void BindToObject([In] string pocsUrl, [In] UUID riid, IntPtr ppvOut); //Binds to an object. does not work!
new object EnumUrls { [return: MarshalAs(UnmanagedType.IUnknown)] get;} //Returns an enumerator for URLs

void AddUrlAndNotify(string pocsUrl, string pocsTitle, int dwFlags, int fWriteHistory, object poctNotify, object punkISFolder);//does not work!
void ClearHistory(); //Removes all history items


}

//UrlHistory class
[ComImport]
[Guid("3C374A40-BAE4-11CF-BF7D-00AA006946EE")]
public class UrlHistoryClass
{

}


}
Joe_Stone 2008-07-10
  • 打赏
  • 举报
回复
你可以用360卫士清除.
nashina 2008-07-10
  • 打赏
  • 举报
回复
要在软件里实现吗
ericzhangbo1982111 2008-07-10
  • 打赏
  • 举报
回复

[DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr FindFirstUrlCacheEntry([MarshalAs(UnmanagedType.LPTStr)] string lpszUrlSearchPattern, IntPtr lpFirstCacheEntryInfo, ref int lpdwFirstCacheEntryInfoBufferSize);

[DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool FindNextUrlCacheEntry(IntPtr hEnumHandle, IntPtr lpNextCacheEntryInfo, ref int lpdwNextCacheEntryInfoBufferSize);

[DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool FindCloseUrlCache(IntPtr hEnumHandle);

[DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool DeleteUrlCacheEntry([MarshalAs(UnmanagedType.LPTStr)] string lpszUrlFileName);

halk 2008-07-10
  • 打赏
  • 举报
回复
你想怎么删?在程序里写代码删?

如果只是想删除这些文件的话,那么重启动到安全模式,然后到这个文件夹全部删除便可。

110,896

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧