Solved

delete temporary internet files

Posted on 2002-04-29
7
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 31

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 31

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 31

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

691 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