情况背景
之前朋友让模仿的一个QQ群验证的Windows Form程序,需要加清除缓存的功能。关于判断登录的QQ是否已经加入指定的QQ群点击查看。由于使用的是.net 自带的WebBrower控件,其本身也是IE浏览器,所以只需要清除IE浏览器的缓存就可以了。这里调用RunDll32.exe来实现IE浏览器的缓存清除!
代码实现
public void IEClear()
{
try
{
Process process = new Process();
process.StartInfo.FileName = "RunDll32.exe";
process.StartInfo.Arguments = "InetCpl.cpl,ClearMyTracksByProcess 255";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
}
catch
{
}
}
关于RunDll32.exe其他参数
//Temporary Internet Files (Internet临时文件)
//RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
//Cookies
//RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
//History (历史记录)
//RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
//Form Data (表单数据)
//RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
//Passwords (密码)
//RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
//Delete All (全部删除)
//RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
//Delete All – “Also delete files and settings stored by add-ons”
//RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351
转载请注明:清风亦平凡 » .net C#实现IE浏览器缓存清除