爱
爱与和平
Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个使用wininet的程序,总是出错,我现在把出错的部分分离出来了,如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,WinINet, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
FINet: HInternet;
FFtpHandle: HInternet;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
FindData: TWin32FindData;
FindHandle: HInternet;
Len: dword;
S: string;
begin
finet:=internetopen('main',0,nil,0,0);
FftpHandle := InternetConnect(FINet, PChar('ftp.borland.com'), 0,
PChar('anonymous'), PChar('abc@abc.com'),
Internet_Service_Ftp, 0, 255);
if FFtpHandle = nil then
showmessage('Á¬½Óʧ°Ü')
else begin
FindHandle := FtpFindFirstFile(FFtphandle, pchar('/*.*'),
FindData, 0, 0);
end;
repeat
if ((finddata.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY) and (finddata.cFileName[1]<>'.')and (finddata.cFileName[0]<>'.')) then
begin
Len:= 0;
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
SetLength(S, Len);
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
showmessage(s+finddata.cFileName);[red]//应该显示/+目录,但总是显示/[/red]
showmessage(finddata.cFileName+s);[red]//这个能正常显示目录+/[/red]
end;
until InternetFindnextFile(FindHandle, @FindData)=false;
end;
end.
为什么丫,这个问题让我抓狂很多天了,请大侠们伸出援助之手,帮帮小弟我吧
PS:上面的代码可以运行,不要让我用第三方控件哦
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,WinINet, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
FINet: HInternet;
FFtpHandle: HInternet;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
FindData: TWin32FindData;
FindHandle: HInternet;
Len: dword;
S: string;
begin
finet:=internetopen('main',0,nil,0,0);
FftpHandle := InternetConnect(FINet, PChar('ftp.borland.com'), 0,
PChar('anonymous'), PChar('abc@abc.com'),
Internet_Service_Ftp, 0, 255);
if FFtpHandle = nil then
showmessage('&Aacute;&not;&frac12;&Oacute;&Ecirc;§°&Uuml;')
else begin
FindHandle := FtpFindFirstFile(FFtphandle, pchar('/*.*'),
FindData, 0, 0);
end;
repeat
if ((finddata.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY) and (finddata.cFileName[1]<>'.')and (finddata.cFileName[0]<>'.')) then
begin
Len:= 0;
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
SetLength(S, Len);
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
showmessage(s+finddata.cFileName);[red]//应该显示/+目录,但总是显示/[/red]
showmessage(finddata.cFileName+s);[red]//这个能正常显示目录+/[/red]
end;
until InternetFindnextFile(FindHandle, @FindData)=false;
end;
end.
为什么丫,这个问题让我抓狂很多天了,请大侠们伸出援助之手,帮帮小弟我吧
PS:上面的代码可以运行,不要让我用第三方控件哦