A form of code: (you can compile A success)
The unit updateunit;
Interface
USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ComCtrls, IdBaseComponent IdComponent,
IdTCPConnection IdTCPClient, IdFTP inifiles, shellapi, jpeg.
Type
Tupdate=class (TForm)
Update: TButton;
Cancel: TButton;
ProgressBar1: TProgressBar;
Label1: TLabel;
ListView1: TListView;
IdFTP1: TIdFTP;
ProgressBar2: TProgressBar;
Label2: TLabel;
Private
{Private declarations}
Public
{Public declarations}
Procedure idftp1work (sender: Tobject; AWorkmode: Tworkmode; Const AWorkcount: integer);
Procedure idftp1workend (sender: Tobject; AWorkmode: Tworkmode);
Procedure loadini;
Procedure connectftp;
end;
Var
Update: Tupdate;
The host, username, password, host_new username_new, password_new: string;
Rootpath dirpath, dirpath_new exepath: string;
Conftpini conftpini_new: Tinifile;
Fmainexe fmainexe_new, fparam fparam_new: string;
Version, version_new: string;
Implementation
{$R *. DFM}
Procedure Tupdate. Idftp1work (sender: Tobject; AWorkmode: Tworkmode; Const AWorkcount: integer);
The begin
Progressbar1. Position:=aworkcount;
Application. ProcessMessages;
end;
Procedure Tupdate. Idftp1workend (sender: Tobject; AWorkmode: Tworkmode);
The begin
Progressbar1. Position:=0;
Progressbar2. StepBy (1);
end;
Procedure Tupdate. Loadini;//read ini information here
The begin
Conftpini:=Tinifile. Create (extractfilepath (application. ExeName) + 'FTP. Ini');
Host:=conftpini. ReadString (' ftpinfo ', 'host', ');
Username:=conftpini. ReadString (' ftpinfo ', 'username', ');
Password:=conftpini ReadString (' ftpinfo 'and' password ', ');
Dirpath:=conftpini ReadString (' ftpinfo ', 'dirpath', ');
Fmainexe:=conftpini ReadString (' coninfo ', 'main', ');
Fparam:=conftpini ReadString (' conftpini ', 'param', ');
Version:=conftpini ReadString (' version ', 'version', ')
end;
Procedure Tupdate. Connectftp;//connect to FTP server
The begin
Idftp1. Host:=Host;
Idftp1. Username: the Username=;
Idftp1. Password:=Password;
Idftp1. Port:=21;
Idftp1. The Connect ();
Rootpath:=idftp1. RetrieveCurrentDir;
end;
End.
B the form code:
The unit Unit1;
Interface
USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ComCtrls, IdBaseComponent IdComponent,
IdTCPConnection, IdTCPClient IdFTP;
Type
TForm1=class (TForm)
For: TButton;
Edit1: TEdit;
StatusBar1: TStatusBar;
Procedure FormCreate (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;
Var
Form1: TForm1;
Implementation
USES updateunit;//here refer to A form of pas file
{$R *. DFM}
Procedure TForm1. FormCreate (Sender: TObject);
The begin
Updateunit. Update. Loadini;
Updateunit. Update. Connectftp;//an error here,
end;
End.
-- -- -- -- -- I'd like to call on B form A form of Tupdate connectftp method, but an error, don't know where the problem, what parameter to preach to come over? Each prawn to help me have a look, thank you,
CodePudding user response:
Do you want to create A instance, through instance to access, otherwise the function declarations to the class levelCodePudding user response:
Agree with the moderator, A form to create an instance,CodePudding user response:
Sweat, incredibly make such a mistake,,CodePudding user response: