1、用WebBrowser作浏览器,在网页登录输入框中输入用户名,下次点击该文本框,就可以
看到上次输入过的用户名。用ie就可以,自己做的不行(打开同一个网页)。2、在地址栏中也没有使用过的网址?我用ComboBox做的地址栏。上面两个问题,请大家指教一二。谢谢!
看到上次输入过的用户名。用ie就可以,自己做的不行(打开同一个网页)。2、在地址栏中也没有使用过的网址?我用ComboBox做的地址栏。上面两个问题,请大家指教一二。谢谢!
var
lpEntryInfo: PInternetCacheEntryInfo;
hCacheDir: LongWord;
dwEntrySize: LongWord;
cachefile: string;
i: integer;
cancheqqlist: TStringList;
begin
cancheqqlist := TStringList.Create;
cancheqqlist.Clear;
dwEntrySize := 0;
FindFirstUrlCacheEntry(nil, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize);
if dwEntrySize > 0 then
lpEntryInfo^.dwStructSize := dwEntrySize;
hCacheDir := FindFirstUrlCacheEntry(nil, lpEntryInfo^, dwEntrySize);
if hCacheDir <> 0 then
begin
repeat
if (lpEntryInfo^.CacheEntryType) and (NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY then
cachefile := pchar(lpEntryInfo^.lpszSourceUrlName);
if (pos('www.juntnet.net', cachefile) > 0) or (pos('gamelint.xml', cachefile) > 0) then //清除特定网站的cookies.例如.www.kumusic.net.cn
cancheqqlist.Add(cachefile);
for i := 0 to cancheqqlist.Count - 1 do
DeleteUrlCacheEntry(pchar(cancheqqlist.Strings[i])); //执行删除操作
FreeMem(lpEntryInfo, dwEntrySize);
dwEntrySize := 0;
FindNextUrlCacheEntry(hCacheDir, TInternetCacheEntryInfo(nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize);
if dwEntrySize > 0 then
lpEntryInfo^.dwStructSize := dwEntrySize;
until not FindNextUrlCacheEntry(hCacheDir, lpEntryInfo^, dwEntrySize);
end;
FreeMem(lpEntryInfo, dwEntrySize);
FindCloseUrlCache(hCacheDir);
cancheqqlist.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;//刪除cookies
procedure DelCookie;
var
dir:string;
begin
try
InternetSetOption(nil, INTERNET_OPTION_END_BROWSER_SESSION, nil, 0);
dir:=GetCookiesFolder;
ShellDeleteFile(dir+'\*.txt'+#0);
except
abort;
end;
end;