Re: IdFtp using C++ (errors)

Giganews Newsgroups
Subject: Re: IdFtp using C++ (errors)
Posted by:  Remy Lebeau (TeamB) (
Date: Tue, 6 Sep 2005

"Joe Pool" <jpo…> wrote in message

>  void __fastcall TForm1::FormCreate(TObject *Sender)  {

NEVER NEVER NEVER use the OnCreate event in C++!!!  It is a Delphi idiom
that causes illegal behavior in C++ as it can be triggered before the

>  TStringList* List1;

You have declared an uninitialized pointer...

>  IdFtp1->List(List1, "*.*", true);

... which you are then passing to List() without actually creating any valid
TStringList object first.  You need to change ths line:

    TStringList* List1;

To this instead:

    TStringList* List1 = new TStringList;

And don't forget to free the memory after you are done using it:

    delete List1;

> I consistantly receive an error whenever I attempt to list the
> contents of the directory (line #17).

That is because your code has a bug in it.

> Here is the error:

An Access Violation means that invalid memory has been accessed.  Since you
never created any actual TStringList object, or even initialized your
pointer to NULL at least, your pointer is initially pointing to a random
memory address.



In response to

IdFtp using C++ (errors) posted by Joe Pool on Tue, 6 Sep 2005