删除IE历史记录的代码怎么写? 软件每次运行需要防问某个网站的页面,准确一点是访问这个网站流媒体文件(如wma文件),我想运行软件后在IE中删除这个网站的历史记录(不删其它网战的历史记录),应该怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 注册表里HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\TypedURLs里存的是IE地址栏的历史记录,找到想删的删除就行了,要调用注册表单元 删除IE临时文件{BOOL bRet = FALSE; HANDLE hEntry; LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL; DWORD dwEntrySize; //delete the files dwEntrySize = 0; hEntry = FindFirstUrlCacheEntry(NULL, NULL, &dwEntrySize); lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize]; hEntry = FindFirstUrlCacheEntry(NULL, lpCacheEntry, &dwEntrySize); if (!hEntry) { goto cleanup; } do { if (type == File && !(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY)) { DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName); } else if (type == Cookie && (lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY)) { DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName); } dwEntrySize = 0; FindNextUrlCacheEntry(hEntry, NULL, &dwEntrySize); delete [] lpCacheEntry; lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize]; } while (FindNextUrlCacheEntry(hEntry, lpCacheEntry, &dwEntrySize)); bRet = TRUE;cleanup: if (lpCacheEntry) { delete [] lpCacheEntry; } return bRet;}浏览器地址栏历史地址的清除SHDeleteKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Internet Explorer\\TypedURLs");// 清浏览网址历史记录 HRESULT hr; TCHAR szPath[MAX_PATH]; IUrlHistoryStg2* pUrlHistoryStg2 = NULL; hr = CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2, (void**)&pUrlHistoryStg2); if (SUCCEEDED(hr)) { hr = pUrlHistoryStg2->ClearHistory(); pUrlHistoryStg2->Release(); } // 如果上面代码不能清 // 则有下面的,不完美,但能工作. GetWindowsDirectory(szPath, MAX_PATH); _tcscat(szPath, _T("\\History")); EmptyDirectory(szPath, FALSE, TRUE); if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_HISTORY, FALSE)) { EmptyDirectory(szPath, FALSE, TRUE); } 在注册表中HKEY_CURRENT_USER Software\\Microsoft\\Internet Explorer\\TypedURLs,uses Registry;...删除所有分支内容就可以的 好象还有一个api函数可以实现的,ClearHistory......你在msdn找找 unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,Registry,wininet,FileCtrl,shlobj,shellapi;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}procedure DelRegCache;var reg:TRegistry;begin reg:=Tregistry.create; reg.RootKey:=HKEY_CURRENT_USER; reg.DeleteKey('Software\Microsoft\Internet Explorer\TypedURLs'); reg.Free;end;function GetCookiesFolder:string;var pidl:pItemIDList; buffer:array [ 0..255 ] of char ;begin SHGetSpecialFolderLocation( application.Handle , CSIDL_COOKIES, pidl); SHGetPathFromIDList(pidl, buffer); result:=strpas(buffer);end;function ShellDeleteFile(sFileName: string): Boolean;var FOS: TSHFileOpStruct;begin FillChar(FOS, SizeOf(FOS), 0); {记录清零} with FOS do begin wFunc := FO_DELETE;//删除 pFrom := PChar(sFileName); fFlags := FOF_NOCONFIRMATION; end; Result := (SHFileOperation(FOS) = 0);end;procedure DelCookie;var dir:string;begin InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, 0); dir:=GetCookiesFolder; ShellDeleteFile(dir+'\*.txt');end;procedure DelHistory;var lpEntryInfo: PInternetCacheEntryInfo; hCacheDir: LongWord ; dwEntrySize, dwLastError: LongWord;begin dwEntrySize := 0; FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize); GetMem(lpEntryInfo, dwEntrySize); hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize); if hCacheDir <> 0 then DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName); FreeMem(lpEntryInfo); repeat dwEntrySize := 0; FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize); dwLastError := GetLastError(); if dwLastError = ERROR_INSUFFICIENT_BUFFER then //如果成功 begin GetMem(lpEntryInfo, dwEntrySize); {分配dwEntrySize字节的内存} if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName); FreeMem(lpEntryInfo); end; until (dwLastError = ERROR_NO_MORE_ITEMS);end;procedure TForm1.Button1Click(Sender: TObject);begin try screen.cursor:=crHourGlass; DelRegCache; DelCookie; DelHistory; finally screen.cursor:=crDefault; end;end;end. 关于SPCOMM在接收数据的同时,发送命令出现滞后的问题! SQL多表查询的结果大家如何存储和处理?? excel...我对她又爱又恨 求一个sql语句,我认为有点难度! 急,大虾帮忙!有关数据显示问题 小问题,如何进行错误处理? 再谢星河谷 开心散分:从未开发过PDA项目,时间相当紧迫的情况下一周基本搞定PDA项目 关于 DateTimePicker1控件 用代码控制rave reports 数据库连接问题 多了一个星,散分
临时文件{
BOOL bRet = FALSE;
HANDLE hEntry;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry = NULL;
DWORD dwEntrySize; //delete the files
dwEntrySize = 0;
hEntry = FindFirstUrlCacheEntry(NULL, NULL, &dwEntrySize);
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
hEntry = FindFirstUrlCacheEntry(NULL, lpCacheEntry, &dwEntrySize);
if (!hEntry)
{
goto cleanup;
} do
{
if (type == File &&
!(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
{
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
}
else if (type == Cookie &&
(lpCacheEntry->CacheEntryType & COOKIE_CACHE_ENTRY))
{
DeleteUrlCacheEntry(lpCacheEntry->lpszSourceUrlName);
} dwEntrySize = 0;
FindNextUrlCacheEntry(hEntry, NULL, &dwEntrySize);
delete [] lpCacheEntry;
lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) new char[dwEntrySize];
}
while (FindNextUrlCacheEntry(hEntry, lpCacheEntry, &dwEntrySize)); bRet = TRUE;
cleanup:
if (lpCacheEntry)
{
delete [] lpCacheEntry;
}
return bRet;
}
浏览器地址栏历史地址的清除
SHDeleteKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Internet Explorer\\TypedURLs");
// 清浏览网址历史记录
HRESULT hr;
TCHAR szPath[MAX_PATH];
IUrlHistoryStg2* pUrlHistoryStg2 = NULL;
hr = CoCreateInstance(CLSID_CUrlHistory, NULL,
CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,
(void**)&pUrlHistoryStg2);
if (SUCCEEDED(hr))
{
hr = pUrlHistoryStg2->ClearHistory();
pUrlHistoryStg2->Release();
} // 如果上面代码不能清
// 则有下面的,不完美,但能工作.
GetWindowsDirectory(szPath, MAX_PATH);
_tcscat(szPath, _T("\\History"));
EmptyDirectory(szPath, FALSE, TRUE); if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_HISTORY, FALSE))
{
EmptyDirectory(szPath, FALSE, TRUE);
}
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Registry,wininet,FileCtrl,shlobj,shellapi;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
procedure DelRegCache;
var
reg:TRegistry;
begin
reg:=Tregistry.create;
reg.RootKey:=HKEY_CURRENT_USER;
reg.DeleteKey('Software\Microsoft\Internet Explorer\TypedURLs');
reg.Free;
end;function GetCookiesFolder:string;
var
pidl:pItemIDList;
buffer:array [ 0..255 ] of char ;
begin
SHGetSpecialFolderLocation(
application.Handle , CSIDL_COOKIES, pidl); SHGetPathFromIDList(pidl, buffer);
result:=strpas(buffer);
end;function ShellDeleteFile(sFileName: string): Boolean;
var
FOS: TSHFileOpStruct;
begin
FillChar(FOS, SizeOf(FOS), 0); {记录清零}
with FOS do
begin
wFunc := FO_DELETE;//删除
pFrom := PChar(sFileName);
fFlags := FOF_NOCONFIRMATION;
end;
Result := (SHFileOperation(FOS) = 0);
end;procedure DelCookie;
var
dir:string;
begin
InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, 0);
dir:=GetCookiesFolder;
ShellDeleteFile(dir+'\*.txt');
end;procedure DelHistory;
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord ;
dwEntrySize, dwLastError: LongWord;
begin
dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize); hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
FreeMem(lpEntryInfo); repeat
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^),
dwEntrySize);
dwLastError := GetLastError();
if dwLastError = ERROR_INSUFFICIENT_BUFFER then //如果成功
begin
GetMem(lpEntryInfo, dwEntrySize); {分配dwEntrySize字节的内存}
if FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize) then
DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);
FreeMem(lpEntryInfo);
end;
until (dwLastError = ERROR_NO_MORE_ITEMS);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
try
screen.cursor:=crHourGlass;
DelRegCache;
DelCookie;
DelHistory;
finally
screen.cursor:=crDefault;
end;
end;end.