ini - Delphi XE6: How to load resource into TMemIniFile? -


i've been running delphi xe6 , trying put read-only ini files exe file.

that have solved. loading files working fine tmemo.

i have defined following function loading pure txt ini file resource tmemo:

procedure loadtxtfromresource(const resourcename: string; outmemo: tmemo);  var   resourcestream: tresourcestream;  begin   resourcestream := tresourcestream.create(hinstance, resourcename, rt_rcdata);   try     outmemo.lines.loadfromstream(resourcestream);       resourcestream.free;   end; end; 

it working flawlessly.

now, need, re-write procedure load aforementioned text file tmeminifile.


i've been trying various things, can't seem able that. hints?

you need load resource stream string list, , transfer tmeminifile.

procedure loadinifromresource(const resourcename: string; inifile: tmeminifile); var   resourcestream: tresourcestream;   text: tstringlist; begin   resourcestream := tresourcestream.create(hinstance, resourcename, rt_rcdata);   try     text := tstringlist.create;     try       text.loadfromstream(resourcestream);       inifile.setstrings(text);           text.free;     end;       resourcestream.free;   end; end; 

note because tmeminifile not file based, must pass empty string file name when instantiating it:

inifile := tmeminifile.create(''); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -