SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Accessing XML resource from Delphi5

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> Resource Builder
View previous topic :: View next topic  
Author Message
AdeHolt



Joined: 08 Mar 2006
Posts: 1

PostPosted: Wed Mar 08, 2006 6:03 pm    Post subject: Accessing XML resource from Delphi5 Reply with quote

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
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Thu Mar 09, 2006 3:54 pm    Post subject: Reply with quote

Just use
Code:
tmpStream := TResourceStream.Create(HInstance, 'XML_PRICER_REPORT', 24);

Please let me know if this helps.
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Thu Mar 09, 2006 3:57 pm    Post subject: Reply with quote

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:
tmpStream := TResourceStream.Create(HInstance, 'XML_PRICER_REPORT', 'XML_TYPE');

So resource script will look like:
Code:
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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> Resource Builder All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group