how to use system.xml.dll in delphi - delphi

I downloaded the system.xml.dll, then added it to my Delphi code as following:
uses system.xml;
etc...
When I try to compile the project, the following message appears:
file not found system.xml.dcu.
Can anyone guide me how to solve this problem?
Thanks.

The uses clause in Delphi refers to Delphi units, either compiled in a *.dcu file or a *.pas source file that the compiler will use to generate the corresponding *.dcu that is needed.
You cannot just reference the DLL itself.
To use your DLL, you would need at least a unit that would expose in a Pascal way the DLL interface or parts of it.
It can be the Pascal translation of a C header file or just declaring some external routines from the dll to load statically with your program...
What you probably need to reference to work with XML in Delphi are XMLIntf and maybe xmldom.
Have you looked at what the XML Data binding wizard or the XML Mapper Tool can do for you?
Note: I assumed you were working with Delphi Win32. And AFAIK system.xml.dll is part of the .NET world.

If you are using Delphi for .Net you need to add a reference to the system.xml.dll assembly to your project.

If you are using Delphi (Win32), then in order to be able to use .NET assemblies (DLLs), you have the option of using COM interfaces. Follow below steps:
Open the project you want to use it in.
Use Component menu.
Select "Import Type Library"
Select the DLL you want to use.
Follow the next steps as given by wizard.
This will generate a source file which is essentially a wrapper. You can call function of that wrapper as you need.
Please note that using above method will mean that .NET framework must be present on the computer running your application.

Related

How can I link a static lib generated by DCC32 with the option -JL in C++builder?

I'm trying to use a static library in my C++ Builder project. The lib is created by using DCC32 to compile Delphi source code with -JL option. My Delphi source code is design as a "Designtime and runtime" package, which mean s all the code is built into one package. I want to know how can I use this static library in our C++ Builder project? Thanks in advance.
As David said, the Delphi compiler can't create static lib files at all. What you are trying to link to is an import library for a designtime/runtime package.
Delphi (and C++Builder) packages are not static libs, they are DLLs with a lot of extra information onboard, which makes it easy for Delphi and C++Builder code to link to them and the types inside. They are more or less equivalent to C# assemblies (guess where the C# people got the idea ;-).
To use such a package, in case you really want to use them, select the "build with packages" option from the project options and select this package too.
But if you want to create a single, standalone application, you don't build with packages and the Pascal files get linked into your application as if they came from a static library. But instead of specifying one lib file, you simply specify the .pas files in the project manager, i.e. you simply add the bunch of .pas (or .obj) files to your application directly.
The project will take care of compiling the Pascal files and linking them to your application.
Note that to install components into the IDE, you need a design time package (and that might link to a runtime package). But you don't need packages for your application.
These are some steps for your consideration:
Use -JP to generate obj files
Add these obj files in link step into your ilink32 command
If you use IDE and do not which ilink32 params then you may consider procexp or procmon to see these params.

Delphi unit for msctf.h header file (from Platform SDK)?

Is there any Delphi unit available corresponding msctf.h header file from Platform SDK?
I have checked Delphi 2010 source folder, but it seems Delphi doesn't come with that.
Thanks in advance for your time!
You can use Visual Studio's MIDL to generate a type library (.tlb) from the .idl file and then use Delphi's tlibimp.exe to generate the Delphi interface unit.
The problem with the original .idl is that it doesn't contain a library statement so I added it manually (otherwise MIDL wouldn't generate the .tlb).
See if the result helps you (you may still need to fix some parts by hand).

Using COM DLLs with FSI

Is there a way within FSI that I can reference and use registered COM components?
In a normal .fs compiled program I can simply reference the component in question and then open the relevant generated namespace(s). In a .fsx file, however, I can't seem to replicate this behaviour. I have tried using #r to reference the .dll directly, and I have tried using #I to point to the directory followed #r both with the library's "friendly" name and the file name, but nothing seems to work.
Are you only able to reference .NET assemblies from a .fsx? I don't really want to have to write/gen a wrapper assembly. I am hoping there might be a way to force FSI to take whatever steps the normal executable takes in order to provide the interop layer.
When you add a reference to a COM component in Visual Studio, it invokes a tool to generate a wrapper (standard .NET assembly) and then references the wrapper.
If you want to reference COM from fsx, you'll need to generate the wrapper yourself (or find the one generated by Visual Studio?) The tool that generates the wrapper that is called TlbImp.exe (see Type Library Importer on MSDN).

Importing .net dll to Delphi 6 loses information

I have a .net dll which I could import to Delphi 6. But it loses some information.
I have a demo application in VB.net to use this dll which shows 2 interfaces called
IRedeemTransactionItemBundle and ITransactionItemBundle. In Visual Studio 2008 I could see that ITransactionItemBundle is the base type of IRedeemTransactionItemBundle. So when I declare a variable of type IRedeemTransactionItemBundle, I could access all properties of both interfaces.
But when I import the dll to Delphi 6, I could see both IRedeemTransactionItemBundle and ITransactionItemBundle declaration part. But there is no information that shows ITransactionItemBundle is the base type of IRedeemTransactionItemBundle. Also when I declare a variable of type IRedeemTransactionItemBundle in Delphi, I am not able to access properties of ITransactionItemBundle (the base type).
When I tried to register the library in tlb editor by setting the base type of IRedeemTransactionItemBundle to ITransactionItemBundle, I am getting the error: “Parent Interface already has a member with id:1610743808”. I could see properties of both interfaces have same ID in the tlb editor.
I tried to import the same dll using Delphi 7 also. But no help.
Is that a problem with Delphi? Have any of you experienced such a problem in importing kindly give me some thoughts?
I would suggest you to make COM visible wrapper for the DLL in C# or VB.NET which will import necessary functionality in the way Delphi can interact with correctly.
Apart from using COM interop, you can do an unmanaged export. Simply put, you need a new specific version of the .net dll.
Please head to this post for details of the technique using Delphi.

How to consume and re-expose a Win32 type library using Delphi Prism

I currently have a Win32 type library created in Delphi which I need to consume, implement and re-expose via .NET. What are the steps necessary to bring the TLB into Prism so the interface can be implemented?
the .NET 2.0 sdk tool TLBIMP can create an assembly from a TLB file. Something like:
tlbimp.exe mytlb.tlb /out:MyTLB.Import.dll /namespace:MyTLBImport
Make sure you use /publickey /keyfile or /keycontainer if you want to sign it later on.
After the import, just reference the dll and use it as a regular library.

Resources