home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 53 / IOPROG_53.ISO / soft / c++ / xceedftp.exe / Samples / Delphi / Console / console.dpr next >
Encoding:
Text File  |  2000-10-05  |  2.6 KB  |  73 lines

  1. program console;
  2. {------------------------------------------------------------------------------}
  3. { Console sample application using the Xceed FTP Library v1.0                  }
  4. { For Delphi 3, 4 and 5                                                        }
  5. {                                                                              }
  6. { This sasmple connects to an FTP server, lists the contents of the default    }
  7. { folder and then disconnects                                                  }
  8. {                                                                              }
  9. { ** NOTE! **                                                                   }
  10. { In order to compile this application the "Generate Console Application"      }
  11. { must be checked in the Project/Options Linker tab                            }
  12. {                                                                              }
  13. { Copyright (c) 2000 Xceed Software Inc.                                       }
  14. {------------------------------------------------------------------------------}
  15.  
  16. uses
  17.   XceedFtpLib_TLB,  { Wrapper automatically created by Delphi }
  18.   ActiveX,          { For CoInitialize }
  19.   SysUtils,
  20.   events in 'events.pas';
  21.  
  22. {$R *.RES}
  23.  
  24. var
  25.   xFtp    : TXceedFtp;
  26.   xEvents : TEventHandler;
  27. begin
  28.   { Initialize COM. This is normally done by Application.Initialize }
  29.   CoInitialize( nil );  { CoInitializeEx also available... }
  30.  
  31.   { Create our XceedFtp instance }
  32.   xFtp := TXceedFtp.Create( nil );
  33.  
  34.   { Create our event handling object, since event handling functions must be
  35.     member methods of an object, and set all event handling methods. }
  36.   xEvents := TEventHandler.Create;
  37.   xFtp.OnListingFolderItem := xEvents.ListingFolderItem;
  38.  
  39.   { Set some properties required in order to connect - change them as needed }
  40.   xFtp.ServerAddress  := 'ftp.cdrom.com';
  41.   xFtp.ServerPort     := 21;
  42.   xFtp.UserName       := 'anonymous';
  43.   xFtp.Password       := 'guest';
  44.  
  45.  try
  46.     WriteLn( 'Connecting to ' + AnsiString(xFtp.ServerAddress) );
  47.     WriteLn( '' );
  48.     xFtp.Connect();
  49.     try
  50.       WriteLn( 'Obtaining directory listing' );
  51.       WriteLn( '' );
  52.       xFtp.ListFolderContents( '' );
  53.     except
  54.       on xErr: Exception do
  55.         WriteLn( xErr.Message );
  56.     end;
  57.     xFtp.Disconnect();
  58.  except
  59.     on xErr: Exception do
  60.       WriteLn( xErr.Message );
  61.   end;
  62.  
  63.   { Wait for user input before quitting! }
  64.   WriteLn( '' );
  65.   WriteLn( 'Done. press ''Enter'' to quit.' );
  66.   ReadLn;
  67.  
  68.   { Free our instance of the XceedFtp object }
  69.   xFtp.Free;
  70.   CoUninitialize();
  71. end.
  72.  
  73.