var
s:string;
begin
SetLength(s,256);
GetWindowsDirectory(PChar(s),256);
ShowMessage(IntToStr(Length(s))); //Length(s) 256
ShowMessage(IntToStr(StrLen(PChar(s))));//StrLen(PChar(s))10
//SetLength(s,StrLen(PChar(s))); //没有这句,会有一堆的空格
ShowMessage(s);
end;