Article View: borland.public.cppbuilder.nativeapi
Article #10911SHGetSpecialFolderPath wired problem..please help
From: Martin C
Date: Sun, 21 Mar 2004 06:33
Date: Sun, 21 Mar 2004 06:33
75 lines
3392 bytes
3392 bytes
Hi all,
I am trying to use SHGetSpecialFolderPath API function to get my Internet
Explorer History folder location and erase all its contents as shown below,
although I have a really wired problem, which is when I try to delete the
history folder contents, sometime it erases all of its contents, sometime
not and sometime it erase some file and leave other files!
So can someone please tell me where is my mistake and why I face such a
weird behavior.
Thanks
void __fastcall TForm1::BrowserHistoryCleaner()
{
CHAR szPath[MAX_PATH];
if(SHGetSpecialFolderPath(NULL, szPath, CSIDL_HISTORY, FALSE))
{ HCSearchForFiles(szPath, "*.*");
}
}
//--------------------------------------------------------------------------
-
bool __fastcall TForm1::HCSearchForFiles(const AnsiString &Folder, const
AnsiString &MaskToFind)
{
WIN32_FIND_DATA wfd;
HANDLE hFind;
String sFullPath, sFindFilter, sCurrentFolder;
bool Result = true;
sCurrentFolder = IncludeTrailingBackslash(Folder);
sFindFilter = sCurrentFolder + "*.*";
hFind = FindFirstFile(sFindFilter.c_str(), &wfd);
if( hFind != INVALID_HANDLE_VALUE )
{
do
{
if( (_tcscmp(wfd.cFileName, _T(".")) == 0) ||
(_tcscmp(wfd.cFileName, _T("..")) == 0) )
continue;
sFullPath = sCurrentFolder + String(wfd.cFileName);
if( wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
{
Result = SetFileAttributes(sFullPath.c_str(),
wfd.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
if(!Result)
break;
}
if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
Result = HCSearchForFiles(sFullPath, MaskToFind);
if(Result)
Result = RemoveDirectory(sFullPath.c_str());
}
else
{
if(MatchesMask(wfd.cFileName, MaskToFind))
{
Result = DeleteFile(sFullPath);
}
}
}
while((Result) && (FindNextFile(hFind, &wfd)));
FindClose(hFind);
}
return Result;
}
//--------------------------------------------------------------------------
--
Technical Details
Message-ID:
<405d9a1b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,2997fc081f04d0de,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-03-21 05:39:18 PST From: "Martin C" <martinc@aol.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: SHGetSpecialFolderPath wired problem..please help Date: Sun, 21 Mar 2004 08:33:36 +0200 Lines: 77 Organization: V Safe X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 62.135.27.30 Message-ID: <405d9a1b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1079876123 62.135.27.30 (21 Mar 2004 05:35:23 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail