Solved

delete temporary internet files

Posted on 2002-04-29
7
299 Views
Last Modified: 2013-11-20
How can i delete temporary internet files programmaticaly using microsoft visual c 6.0?
0
Comment
Question by:spap
  • 3
  • 2
7 Comments
 
LVL 30

Expert Comment

by:Zoppo
ID: 6977329
Hi spap,

you can use SHGetFolderPath() with arg 'CSIDL_INTERNET_CACHE' to retrieve
the folder where Temporary Internet Files are stored and with this folder you can
use i.e. SHFileOperation() to delete all files using wildcards.

hope that helps,

ZOPPO
0
 
LVL 1

Author Comment

by:spap
ID: 6983552
Dear Zoppo the problem is that the cookies or the temporary internet files are system files. as a result the deletion fails to delete the files. what to do about that?
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 6985433
Hmm, bad ... I found that with following code I could delete all those files/cookies:

void CleanDir( TCHAR* szPath, int& iFileCount )
{
 WIN32_FIND_DATA FindFileData;
 HANDLE hFind;

 TCHAR szSubPath[256];
 strcpy( szSubPath, szPath );

 strcat( szSubPath, "\\*.*\0" );

 hFind = FindFirstFile( szSubPath, &FindFileData );

 if (hFind == INVALID_HANDLE_VALUE)
 {
  cout << "Invalid File Handle. Get Last Error reports " << GetLastError() << endl;
  return;
 }

 BOOL bOk = TRUE;
 while ( bOk )
 {
  if ( 0 != stricmp( FindFileData.cFileName, ".." ) && 0 != stricmp( FindFileData.cFileName, "." ) )
  {
   if ( FILE_ATTRIBUTE_DIRECTORY & FindFileData.dwFileAttributes )
   {
    strcpy( szSubPath, szPath );

    strcat( szSubPath, "\\" );
    strcat( szSubPath, FindFileData.cFileName );

    CleanDir( szSubPath, iFileCount );
   }
   else
   {
    cout << "Delete File " << FindFileData.cFileName << " ... ";
 
    strcpy( szSubPath, szPath );

    strcat( szSubPath, "\\" );
    strcat( szSubPath, FindFileData.cFileName );
 
    if ( 0 != unlink( szSubPath ) )
     cout << "Error deleting file: " << GetLastError() << endl;
    else
    {
     iFileCount++;
     cout << "File deleted!" << endl;
    }
   }
  }
 
  bOk = FindNextFile( hFind, &FindFileData );
 }

 FindClose(hFind);
}

void DeleteTempIEFiles()
{
 TCHAR szPath[_MAX_PATH];

 SHGetFolderPath
 (
  NULL,
  CSIDL_INTERNET_CACHE,
  NULL,
  SHGFP_TYPE_CURRENT,
  szPath
 );

 cout << "Folder for temporary internet files is : " << endl << "'" << szPath << "'" << endl;

 int iFileCount = 0;

 CleanDir( szPath, iFileCount );

 cout << iFileCount << " Files deleted!" << endl;
}

hope this helps,

ZOPPO
0
 
LVL 1

Author Comment

by:spap
ID: 6985692
Thanks zoppo. It works perfect.
For the completeness of the porposed answer do you know how to remove the items from the address bar of the internet explorer programmaticaly?

Thank again and best wishes from Greece.
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 200 total points
ID: 6985710
Hi again,

nice to hear it works :o)

to remove history from address bar (I hope you meant the history) you simply need to remove
all entries from registry key HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs

ZOPPO

PS: Greetings from Germany, too ... I bet you have the better weather.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 155
sum28 challenge 31 96
zeroFront challenge 7 71
Problem to open Excel file 15 45
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now