Article View: borland.public.cppbuilder.nativeapi
Article #17370Remove multiple files to Recycle Bin
From: Konstantin Polyakov
Date: Sun, 06 Apr 2003 18:01
Date: Sun, 06 Apr 2003 18:01
43 lines
1983 bytes
1983 bytes
Hello, All!
Please help me to correct the function of removing multiple
files to Recycle Bin. I've made the following:
void TForm1::SendToRecycleBinMulti(TStringList *m1)
{
if (m1->Count == 0) return;
int bfsize = 1;
for(int i=0; i<m1->Count; i++)
{
bfsize+=m1->Strings[i].Length()+1;
}
SHFILEOPSTRUCT SHF;
SHF.hwnd=Application->Handle;
SHF.wFunc=FO_DELETE;
char *n1 = new char[bfsize];
strcpy(n1, m1->Strings[0].c_str());
char* tmp= &n1[strlen(n1)+1];
for(int i=1; i<m1->Count; i++)
{
strcpy(tmp,m1->Strings[i].c_str());
tmp+=strlen(tmp)+1;
}
*tmp='\0';
SHF.fFlags=FOF_ALLOWUNDO|FOF_NOCONFIRMATION;
SHF.pFrom=n1;
if (SHFileOperation(&SHF)!=0) ShowMessage ("Error");
delete []n1;
}
It works but when I trying to put in to the big project, it causes "Access
violation in kernel.dll...". Why ? Please tell me what wrong with this code.
Thanks.
With best regards, Konstantin Polyakov. E-mail: support@chemtable.com
Technical Details
Message-ID:
<3e906b66@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,1c6a0918c882faad,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-06 11:05:53 PST From: "Konstantin Polyakov" <support@chemtable.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Remove multiple files to Recycle Bin Date: Mon, 7 Apr 2003 00:01:08 +0600 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Comment-To: All FL-Build: Fidolook 2002 (SL) 6.0.2600.64 - 21/6/2002 21:54:41 NNTP-Posting-Host: 195.19.136.9 Message-ID: <3e906b66@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049652070 195.19.136.9 (6 Apr 2003 11:01:10 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail