home *** CD-ROM | disk | FTP | other *** search
- program console;
- {------------------------------------------------------------------------------}
- { Console sample application using the Xceed FTP Library v1.0 }
- { For Delphi 3, 4 and 5 }
- { }
- { This sasmple connects to an FTP server, lists the contents of the default }
- { folder and then disconnects }
- { }
- { ** NOTE! ** }
- { In order to compile this application the "Generate Console Application" }
- { must be checked in the Project/Options Linker tab }
- { }
- { Copyright (c) 2000 Xceed Software Inc. }
- {------------------------------------------------------------------------------}
-
- uses
- XceedFtpLib_TLB, { Wrapper automatically created by Delphi }
- ActiveX, { For CoInitialize }
- SysUtils,
- events in 'events.pas';
-
- {$R *.RES}
-
- var
- xFtp : TXceedFtp;
- xEvents : TEventHandler;
- begin
- { Initialize COM. This is normally done by Application.Initialize }
- CoInitialize( nil ); { CoInitializeEx also available... }
-
- { Create our XceedFtp instance }
- xFtp := TXceedFtp.Create( nil );
-
- { Create our event handling object, since event handling functions must be
- member methods of an object, and set all event handling methods. }
- xEvents := TEventHandler.Create;
- xFtp.OnListingFolderItem := xEvents.ListingFolderItem;
-
- { Set some properties required in order to connect - change them as needed }
- xFtp.ServerAddress := 'ftp.cdrom.com';
- xFtp.ServerPort := 21;
- xFtp.UserName := 'anonymous';
- xFtp.Password := 'guest';
-
- try
- WriteLn( 'Connecting to ' + AnsiString(xFtp.ServerAddress) );
- WriteLn( '' );
- xFtp.Connect();
- try
- WriteLn( 'Obtaining directory listing' );
- WriteLn( '' );
- xFtp.ListFolderContents( '' );
- except
- on xErr: Exception do
- WriteLn( xErr.Message );
- end;
- xFtp.Disconnect();
- except
- on xErr: Exception do
- WriteLn( xErr.Message );
- end;
-
- { Wait for user input before quitting! }
- WriteLn( '' );
- WriteLn( 'Done. press ''Enter'' to quit.' );
- ReadLn;
-
- { Free our instance of the XceedFtp object }
- xFtp.Free;
- CoUninitialize();
- end.
-
-