Solved

delete temporary internet files

Posted on 2002-04-29
7
303 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 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Importing Special Characters in Dynamics GP Through Integration Manager 3 75
Looking for a specific application/software 2 109
post4 challenge 28 100
Line meaning 9 85
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

786 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