Mega Code Archive

 
Categories / Delphi / Examples
 

Resourcestring

David, in message <NEBBIDNPNKPOECPOIEGEIEDFCBAA.David.B@Sigma.se>, you wrote: > Does any one have any inside info on resourcestrings? I found out the hard > way that there is a 1024 byte limit on resource strings. Is this a Delphi 5 > limitation or is this a windows limitation? > And finally, is there a way around this? > That is a WinLimit(tm). You can get around it by using RCDATA. simply add a file called whatever.rc to your project. Your file will contain (something like) the following script: THESTUF RCDATA thefile.txt the line above is all that is required. "thefile.txt" will contain your extremely long string. You would retrieve it with the following function: function GetRCDataAsString(const AName: string): string; var resStream: TResourceStream; begin Result := ''; resStream := TResourceStream.Create(HInstance, UpperCase(AName), RT_RCDATA); try if resStream.Size > 0 then begin SetLength(Result, resStream.Size); resStream.ReadBuffer(Result[1], Length(Result)); end; finally resStream.Free; end; end; simply call it like: myString := GetRCDataAsString('THESTUF');