🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12327

Access violation in kernel32.dll using SHFileOperation

#12327
From: Muhammad Momin Rashid
Date: Wed, 10 Dec 2003 09:46
26 lines
1699 bytes
The following code was working a while ago, can someone have a look at it
and kindly inform me where did I go wrong?  GetSelectedDirecotry returns a
valid AnsiString containing a Valid Directory path.

Thanks in advance

  AnsiString asName = GetSelectedDirectory();
  TSHFileOpStruct PtrSHFileOpStruct;

  int iNameLength = asName.Length() + 2;

  char *cName = new char [iNameLength];

  // zero fill array (we need a char string with "two" null terminators
  memset(cName, 0, iNameLength);
  strcpy(cName, asName.c_str());

  PtrSHFileOpStruct.hwnd = Application->Handle;
  PtrSHFileOpStruct.wFunc = FO_DELETE;
  PtrSHFileOpStruct.pFrom = cName;
  PtrSHFileOpStruct.fFlags = FOF_SILENT | FOF_ALLOWUNDO;

  SHFileOperation(&PtrSHFileOpStruct); // *** I have started getting an
access violation here

  delete [] cName;
Technical Details
Message-ID: <3fd6ebef@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,30cf8c6d7d0c236c,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-10 02:09:21 PST
From: "Muhammad Momin Rashid" <momin@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Access violation in kernel32.dll using SHFileOperation
Date: Wed, 10 Dec 2003 14:46:50 +0500
Lines: 28
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
NNTP-Posting-Host: 202.163.125.190
Message-ID: <3fd6ebef@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1071049711 202.163.125.190 (10 Dec 2003 01:48:31 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail