var Cache:TStrings; i :Integer; begin AThread.Connection.ReadStrings(Cache,-1); for i:=0 to cache.Count-1 do begin NYHDD:=TreeView1.Items.AddChild(NP,Cache.Strings[q]); NYHDD.ImageIndex:=0; end; end;
刚你那个帖子里就回你了,不要发string了 把字符串放到stream里 var CX:TStringStream; begin CX:=TStringStream.Create(''); CX.WriteString('硬盘序列号'+#13); CX.WriteString(Trim(spskinedit1.Text)+#13); VpnForm.idtcpclient1.WriteInteger(cx.Size); VpnForm.idtcpclient1.WriteStream(cx, True,False); cx.Free; end; 接收procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread); var len:Integer; stringList:TStringList; stringstream:TStringStream; begin stringList:=TStringList.Create; stringstream:=TStringStream.Create(''); len:= AThread.Connection.ReadInteger; AThread.Connection.ReadStream(stringstream,len); stringList.Text:=Flist.DataString; stringstream.Free; showmessage(stringList.Strings[0]);
谢谢大家...问提不是发和收的问题.这个是我用的取卷标函数 // 卷标 function GetVol(str: string): string;// var Path, VolumeName: array[0..1023] of Char; VolumeSerialNumber, MaximumComponentLength, FileSystemFlags: Cardinal; begin try StrPCopy(Path, str); GetVolumeInformation(Path, VolumeName, SizeOf(VolumeName), @VolumeSerialNumber, MaximumComponentLength, FileSystemFlags, nil, 0); except end; Result := VolumeName; // 卷标 end; 问题在这里GetVol('c')和GetVol('c:\') 结果是不同的.哈哈...解决了.
Cache:TStrings;
i :Integer;
begin
AThread.Connection.ReadStrings(Cache,-1);
for i:=0 to cache.Count-1 do
begin
NYHDD:=TreeView1.Items.AddChild(NP,Cache.Strings[q]);
NYHDD.ImageIndex:=0;
end;
end;
把字符串放到stream里
var
CX:TStringStream;
begin
CX:=TStringStream.Create('');
CX.WriteString('硬盘序列号'+#13);
CX.WriteString(Trim(spskinedit1.Text)+#13);
VpnForm.idtcpclient1.WriteInteger(cx.Size);
VpnForm.idtcpclient1.WriteStream(cx, True,False);
cx.Free;
end;
接收procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
len:Integer;
stringList:TStringList;
stringstream:TStringStream;
begin
stringList:=TStringList.Create;
stringstream:=TStringStream.Create('');
len:= AThread.Connection.ReadInteger;
AThread.Connection.ReadStream(stringstream,len);
stringList.Text:=Flist.DataString;
stringstream.Free;
showmessage(stringList.Strings[0]);
// 卷标
function GetVol(str: string): string;//
var
Path, VolumeName: array[0..1023] of Char;
VolumeSerialNumber, MaximumComponentLength, FileSystemFlags: Cardinal;
begin
try
StrPCopy(Path, str);
GetVolumeInformation(Path, VolumeName, SizeOf(VolumeName), @VolumeSerialNumber, MaximumComponentLength, FileSystemFlags, nil, 0);
except
end;
Result := VolumeName; // 卷标
end;
问题在这里GetVol('c')和GetVol('c:\')
结果是不同的.哈哈...解决了.