分我要了[
][
][
]
var s:string;
begin
GetCacheVerifyCodeFile('http://blog.china.com/image.jsp',s);
s为返回缓存中最新的图片路径
只要加载s到image中即可
end;
如果在缓存中没有,可以用抓图方式,抓webbrowser中的验证码位置的图
Function GetCacheVerifyCodeFile(VerifyCodeURL: String; Var CacheVerifyCodeFile: String): boolean;
Var
lpEntryInfo: PInternetCacheEntryInfo;
dwEntrySize, dwLastError, Hwd: LongWORD;
i, j: integer;
f: String;
Begin
result := false;
dwEntrySize := 0;
j := 0;
CacheVerifyCodeFile := '';
FindFirstUrlCacheEntry(Nil, TInternetCacheEntryInfo(Nil^), dwEntrySize);
GetMem(lpEntryInfo, dwEntrySize);
Hwd := FindFirstUrlCacheEntry(Nil, lpEntryInfo^, dwEntrySize);
If Hwd <> 0 Then
Begin
Repeat
dwEntrySize := 0;
FindNextUrlCacheEntry(Hwd, TInternetCacheEntryInfo(Nil^), dwEntrySize);
dwLastError := GetLastError();
If dwLastError = ERROR_INSUFFICIENT_BUFFER Then
Begin
GetMem(lpEntryInfo, dwEntrySize);
If FindNextUrlCacheEntry(Hwd, lpEntryInfo^, dwEntrySize) Then
If Pos(UpperCase(VerifyCodeURL), UpperCase(lpEntryInfo.lpszSourceUrlName)) > 0 Then
Begin
i := FileAge(lpEntryInfo.lpszLocalFileName);
If i > j Then
Begin
j := i;
f := lpEntryInfo.lpszLocalFileName;
End;
End;
End;
Application.ProcessMessages;
Until (dwLastError = ERROR_NO_MORE_ITEMS);
If FileExists(f) Then
Begin
CacheVerifyCodeFile := f;
result := true;
End;
End;
FreeMem(lpEntryInfo);
FindCloseUrlCache(Hwd);
End;