ftpGetCurrentDirectory怎么用?(100分)

  • 主题发起人 主题发起人 jacer
  • 开始时间 开始时间
J

jacer

Unregistered / Unconfirmed
GUEST, unregistred user!
以下出自 Charlie Calvert 《DELPHI AND THE INTERNET》
function TMyFtp.GetCurrentDirectory: string;
var
Len: Integer;
S: string;
begin
Len := 0;
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len); << 这里
SetLength(S, Len);
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
Result := S;
end;

FFTPHandle:Pointer; 取InternetConnect的返回值。
可是编译通不过,错误:
Types of actual and formal var parameters must be identical
究竟错在哪?
 
ftpGetCurrentDirectory这个函数的定义是怎么写的?
我怎么找不到这个函数。
 
函数原型是怎么样的?
 
Syntax:
BOOL FtpGetCurrentDirectory(
HINTERNET hConnect,
LPTSTR lpszCurrentDirectory,
LPDWORD lpdwCurrentDirectory
);

Parameters
hConnect
[in] Valid handle to an FTP session.
lpszCurrentDirectory
[out] Address of a buffer that receives the current directory string, which specifies the absolute path to the current directory. The string is null-terminated.
lpdwCurrentDirectory
[in, out] Address of a variable that specifies the length, in characters, of the buffer for the current directory string. The buffer length must include room for a terminating NULL character. Using a length of MAX_PATH is sufficient for all paths. When the function returns, the variable receives the number of characters copied into the buffer.
Return Value

Returns TRUE if successful, or FALSE otherwise.
 
将Len的类型换为DWord,这样就行了,
function TMyFtp.GetCurrentDirectory: string;
var
Len: DWord;
S: string;
begin
Len := 0;
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len); << 这里
SetLength(S, Len);
ftpGetCurrentDirectory(FFTPHandle, PChar(S), Len);
Result := S;
end;
 
后退
顶部