Solved

delete temporary internet files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 69
deburging in oracle form 12 88
WinWaitActive parameters 12 31
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 76
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

13 Experts available now in Live!

Get 1:1 Help Now