본문 바로가기
Delphi/프로시저-함수

IE캐시를 모두 지우기

by MonoSoft 2021. 5. 14.
728x90
반응형

IE캐시를 모두 지우기

 

 

 

uses

  WinInet;

 

 

procedure DeleteIECache;

var

  lpEntryInfo: PInternetCacheEntryInfo;

  hCacheDir: LongWord;

  dwEntrySize: LongWord;

begin

  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

      DeleteUrlCacheEntry(lpEntryInfo^.lpszSourceUrlName);

      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);

end;

 

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  DeleteIECache;

end;



728x90
반응형

댓글