Hi list, I've noticed some code of mine using resources needed the windows unit (to get RT_RCDATA), Iand therefore wasn't cross-platform.
Tried rewriting using fcl-res, which seems to work ok at least on Windows: uses ,resource //resource readers ,resreader, coffreader, winpeimagereader, elfreader, machoreader //misc ,elfconsts, cofftypes, machotypes; ... Resources:=TResources.Create; ResourceStream:=TMemoryStream.Create; try // ====>>>>>> problem here Resources.LoadFromFile(Paramstr(0)); //load from exe. Isn't there a more elegant way of doing this? // ====>>>>>> end of problem for ResourceCounter:=0 to Resources.Count-1 do begin // Make sure we get the correct resource (must match .rc values): if (Resources[ResourceCounter]._Type.Name='RCDATA') and (Resources[ResourceCounter].Name.Name='SQLSCRIPT') then begin ResourceStream.CopyFrom(Resources[ResourceCounter].RawData, Resources[ResourceCounter].RawData.Size); break; end; end; if ResourceStream.Size=0 then raise Exception.Create('Cannot load SQL script as a resource from the executable.'); In the code above, I'm loading the resource from the executable. However, Paramstr(0) is not reliable on all platforms. Is there a better way of doing this? Thanks, Reinier _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal