Writing a string to a TFileStream in Delphi 2010
问题 I have Delphi 2007 code that looks like this: procedure WriteString(Stream: TFileStream; var SourceBuffer: PChar; s: string); begin StrPCopy(SourceBuffer,s); Stream.Write(SourceBuffer[0], StrLen(SourceBuffer)); end; I call it like this: var SourceBuffer : PChar; MyFile: TFileStream; .... SourceBuffer := StrAlloc(1024); MyFile := TFileStream.Create('MyFile.txt',fmCreate); WriteString(MyFile,SourceBuffer,'Some Text'); .... This worked in Delphi 2007, but it gives me a lot of junk characters in