Delphi4 XE / iOS / read XML file / - ios

Am I correct in that Delphi 4 XE Pro does not supply any native way of reading XML documents? (TXMLDocument is Windows only) I have pondered about using TClientDataSet, but I am not sure if that is the right way to go.
Here is an example of what I want:
Readonly XML file that defines a list of contacts. In the XML file, it also contains e.g. file path to photo of contact.
Ideally I then want to show the data in e.g. a TListBox (which might mean I need to write my own logic for loading images in/out of memory.)

If validation is not required (as in the linked answer above), try
NativeXml
or
OmniXML
Both are free open source libraries for Delphi, however I have not checked if they can be used on other platforms.
Update: see http://www.kluug.net/omnixml.php and Windows & Mac XML library for delphi XE2

Related

delphi integrate custom file editor into IDE

I have deveoped a custom file type, together with a custom editor (basically a tree with several data pages attached and a few extra buttons). OK, I can run it stand alone and that is fine, and even add it to the tools menu, but I would like to integrate it into the Delphi IDE so that my custom editor (or a similar new version) appears in the IDE, rather like a DFM file has a custom editor. I can find references to most extensions in the Delphi IDE, but not this one. Any guiding hands? Note that this is not a property or component editor (the file type has nothing to do with either of these) nor is it simply syntax highlighting of a text file.
AFAIK it currently isn't possible to reliably integrate a custom editor into the Delphi IDE. The required API simply isn't there. See QC89028 Custom Module support.
During the Delphi 2010 and XE betas I spent most my spare time trying to get a resource editor integrated. Although the effort had the official blessing of Embarcadero and got some, half hearted, support from the IDE engineer, I was never able to get them to deliver on their promises and surface the module API. I eventually abandoned the project.
Update: I've now checked my old correspondence regarding this and it turns out part of the problem was that IOTAModuleCreator (used to implement File|New for custom file types) and IOTAEditorContent (used to transfer data to/from the custom module) only supports text data. Binary data gets mangled.
You can probably do this via an IDE plugin that uses the ToolsAPI (see ToolsAPI.pas in the IDE's source folder (e.g. Program Files (x86)\Embarcadero\Studio\source\ToolsAPI\ToolsAPI.pas.)
For information on writing a plugin in general, see David G Hoyle's excellent blog. Once you know the basics - i.e., write a 'wizard' and get it to do something - you will need to work on integrating your editor.
I have never done this, and so I can't guarantee it is possible. However, some interfaces that look worth investigating and implementing are INTACustomEditorView, which represents a 'view' (file tab when that file is open - think the code editor, Welcome view, type library editor, etc) and IOTAEditorViewServices, to register your custom view. I do not know how you associate a view type with a file type, sorry - possibly something to do with the personality interfaces. You might also be interested in INTACustomEditorSubView which is what creates a tab on the bottom of a file.
Good luck, and if you find a solution please write here so that other people can learn too!

Delphi record to resource [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
how to store settings in resource
I have a record with strings, Integers, etc. This record is used as settings for a file that gets read later. How can I convert a record to binary data (or string) and save to it a RCDATA and read it back to a record? If possible native code and/or WinAPI only. Thanks for your help.
About RCDATA:
i ask google "resource editor opensource delphi"
and it told me http://melander.dk/reseditor/
This program surely can read and write resources.
The page's footer also contains links to three more opensource delphi programs that also can do it.
So i hope you would find what u need there. Among piles of other useful code :-)
But - WHAT RCDATA do you want to use ??? OF what file ? some DLL ? or your own project EXE ?
RCDATA is for reading, not writing. It is not typical use. If the DLL or EXE is loaded - you would not be given rights to write into file new RCDATA. And your own running EXe is always open.
About turning to binary - that is VERY dependent on data types u use. Before you would show the data - no one would be able to tell you for sure.
Most lazy approaches would be:
1) Make mirror class from TComponent with published properties mirroring record fields. Assign those properties from record and do TComponent.SaveToStream.
2) Use JsonObject from Progdigy to make text file in JSon format
3) use some XML to save/read. For example TXMLDocument in higher Delphi versions (but it has its gotchas if created with nil Owner) or Jedi CodeLib has XML.
You can search Torry.net for a lot of XML or JSON libs.
But best of all - Google for "serializing in Delphi" and find tutorial detailing the troubles and solutions.

how to extract all icons from some exe files and insert them to other exe files using Delphi?

I'm using Delphi.
I want to know how to extract (all) the icons from an exe file and insert them into another, preserving the order and the index of the icons.
I found some samples of Delphi code using Google but the problem is that it doesn't extract them all.
And I've found some compiled programs (exes) that do one or the other but not both.
Why do I need this: because I have to start some exe files (that have those icons) from virtualized applications. And I want to make some external exe files that have the same name and the same icons.
Thank you for your help.
The source is available for Colin Wilson's XN Resource Editor. It should have what you need.
http://www.wilsonc.demon.co.uk/d10resourceeditor.htm
Alternatively you have the Delphi sample 'ResXplor'. If it's not distributed in your version it's also avalaible to download here: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE/Delphi/VCL/resXplor/
There was a similar question about extracting icons. PrivateExtractIcons gives you access to specific image sizes in an icon resource, but you need to know the sizes ahead of time, and Microsoft warns that this method is not for general use.
There is a working example of extracting the entire icon resource with all of the image sizes on Delphi Praxis. The example has a problem with 256 pixel images, so it would have to be tweaked to account for these.

EXE without (or encrypted) RCDATA?

I'm compiling my application with Delphi 2010. My problem (it may not be a problem for anybody else) is that when you open that EXE with any resource editor you can see RCDATA which holds forms data. I don't like an idea of my program being "exposed" so I want to ask you is there any trick to remove that information from EXE or encrypt it that nobody (at least from resource editor) can see it?
You may create your forms fully via source.
opposite: you can't use the form designer.
with gexperts you can convert existing forms to source.
encrypting and compressing is not a solution. when the app can load the resources a engineer can it do, too.
I have written a DFM compressor that works inside of the Delphi IDE to compress DFMs at compile time. It then decompresses them on the fly at runtime.
I sell it for $15 US and it comes with src.
It currently works with D7, D2006, D2007 and D2009. I don't own D2010 but I have recently gotten XE and I will be upgrading it and making it available for XE as well in the near future. If someone makes a request for XE, or even D2010 compatibility, I'll work to make that happen sooner.
It's called the DeForM System and can be found here.
I use it for a number of my personal projects.
You would need to modify VCL source code to teach form loader to take resources elsewhere. Also, compilation would require post-build step or stripping resources from the compiled EXE and moving them to a separate encrypted file (for example). All of this is manual work, I never heard of any automation for described tasks.
One thing you could do IF your forms are finalized (i.e. they won't be modified further) is take GExperts and use their Component To Code expert to create forms and their contents in runtime. But modification of such forms will require changes in code.
It actually just holds published property of the components you drop on your forms and the form itself (actually the content of DFM file for each form), not any source code. So even if somebody extracts that data, they can at most produce a form visually looking the same as your form, but none of the codes you wrote for the form.
One way to hide such data from resource editors is to build all the components you use in your form at runtime, not using the form designer. This way, the DFM resource will not contain their data. As far as I remember, there are tools which are able to receive a DFM file as input, and generate runtime code for component creations automatically (e.g. GExpert), so that you could copy\paste the code in your form's OnCreate event-handler.
Another option is to use an EXE compressor. A compressor will compress your EXE file so the content of the file will be changed and not usable until being decompressed. Tools like UPX can compress your EXE file and decompress it on the fly when you execute the EXE. Take note that using known compressors like UPX has the drawback that many cracking tools or crackers can detect them and automatically decompress the EXE before processing it. So if you need more security, you'd better go for custom compressors.
I haven't used it, but Citadel for Delphi does automatic compression and encryption of DFM resources in your EXE. It doesn't look like they've updated past Delphi 2009 yet, but it's exactly what you're looking for.

Is it possible to have Delphi auto-generate event-support code for an imported OLE/COM type library?

I'm trying to generate _TLB import units for Outlook 2003, 2007 and 2010 (and also other OLE servers) analogous to the ones bundled with Delphi for Outlook 2000 and 2002. However, I couldn't get the type library importer to also generate the code for capturing events from the OLE servers that is found in the bundled units. The option to "Generate component wrappers" only creates wrappers for servers that are directly instantiatable but not for objects that are only returned via methods of other objects like TInspector, TExplorer, etc.
I could of course create the event handling code myself but that would be really tedious work.
Does anyone know if the importer contained with Delphi 2010 (tlibimp.exe) can be tweaked to generate that code? I really doubt that back in the day Borland created the existing Outlook2000.pas and OutlookXP.pas units manually...
Are there maybe any other tools around that can do this?
Good question! I never noticed that those components were not created (I only use Word_TLB). After playing a bit with tlibimp I found out that you need the -Yc+ flag. Probably all ignore flags are default on.
NB: this is on Delphi 7 with tlibimp.exe version 7.0.4.453

Resources