?
Solved

Using a dll from Delphi written in .NET

Posted on 2006-05-03
7
Medium Priority
?
1,057 Views
Last Modified: 2010-04-04
I have a third-party dll that includes a class with properties and methods, that I would like to call from my Delphi-project. I have registered the dll succesfully from the command-prompt.

In VBA I have referenced the tlb-file and made an object of the class TestClass using the following syntax:

Dim a_Class As New TestClass

I want to do the same in Delphi. Any thought on how to do that?

Cheers,

Mike
0
Comment
Question by:flycht
5 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 672 total points
ID: 16594694
if the dll is written in .net then you have to used delphi.net (2005/2006 and I think delphi 8 also has support but I am not sure)
then you have to import the dll (try from the menu, components, import - I never worked with delphi grater than 7, so I cannot say for sure where the correct menu path is) . when installing the dll, teh delphi wizard should create the tlb (you should be asked for the path to save it)
then, you just do
uses blabla_tlb; // or whetever you named the import pas file
...
var c:TTestClass;// whatever the name is in the import file
begin
  c:=TTestClass.create();
...
end;

that is the general way of going. it might differ a little (or more) though :D
0
 
LVL 13

Assisted Solution

by:BlackTigerX
BlackTigerX earned 664 total points
ID: 16600016
you mention the "tlb-file", if you have the type library, you can just do

menu project, import type library, select the file, that will create a Delphi unit that you can use to instantiate the classes or use whatever the type library contains
0
 

Author Comment

by:flycht
ID: 16612618
Thanks for your answers. The problem when importing the type library in Delphi 5 is that I get a list of compile errors in mscorlib_TLB where the first one is in line 4515 with the following wording: Type 'Byte' is not yet completely defined. Here is what the code looks like:

4514  Byte = packed record
4515    m_value: Byte;
4516  end;

Any ideas? Do you think that a newer version will help this problem? Or is there any trick with delphi 5.0 to overcome these errors?

Best regards

Michael
0
 
LVL 28

Expert Comment

by:2266180
ID: 16612708
well, that is because Byte and byte are not the same in .NET (.NET is case sensitive, regular delphi is not)
and I don't think you can import a .NET library in a non-.NET delphi.
You could try and rename (using case sensitive search/replace) the Byte in TByte or something that is not yet defined.
0
 

Assisted Solution

by:srisha
srisha earned 664 total points
ID: 16629642
As the BlackTigerX says the simplest way (and might be the only way) is to import as TLB. The problem ur facing might with the datatype that is not compatible to Delphi. Try using different datatype for m_value in .NET.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question