Accessing XML resource from Delphi5

All announcements, questions and issues related to the Resource Builder
Post Reply
AdeHolt
Posts: 1
Joined: Wed Mar 08, 2006 4:21 pm

Accessing XML resource from Delphi5

Post by AdeHolt »

I have used resource builder to add some (static) xml to a res file. This appears in the rc file as

LANGUAGE LANG_NEUTRAL, 0
XML_PRICER_REPORT 24
MOVEABLE PURE LOADONCALL DISCARDABLE
BEGIN
0x723C, 0x7065, 0x726F, 0x2074, 0x6D78, 0x6E6C, 0x3D73, 0x6822,
0x7474, 0x3 ...........

I am trying to access this in Delphi as follows :

tmpStream := TResourceStream.Create(HInstance, 'XML_PRICER_REPORT', 'XML');
try
tmpStream.Read(XmlResult, tmpStream.Size);
OutputDocument.loadXml(XmlResult);
finally
tmpStream.Free;
end;

Delphi complains that it cannot load the resource item XML_PRICER_REPORT.

Has anyone out there any experience of this?

Thanks

Adrian
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Just use

Code: Select all

tmpStream := TResourceStream.Create(HInstance, 'XML_PRICER_REPORT', 24); 
Please let me know if this helps.
Best regards,
Igor Siticov.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Or and most important thing is that MS Windows doesn't always allow to use RT_XML (24) type resources in executable except manifests. So it may fail to load your application. So I would suggest to use something as custom resource type, say XML_TYPE and load it using:

Code: Select all

tmpStream := TResourceStream.Create(HInstance, 'XML_PRICER_REPORT', 'XML_TYPE');
So resource script will look like:

Code: Select all

XML_PRICER_REPORT XML_TYPE
To be able to edit it still as text you can use View-> View as Text menu in Resource Builder.
Best regards,
Igor Siticov.
Post Reply