Book a Demo

Author Topic: Any ideas on a Delphi DLL  (Read 3524 times)

MattV

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Any ideas on a Delphi DLL
« on: March 04, 2003, 03:05:02 pm »
Hi All,

This is the first time that I've used a UML tool, so forgive any ignorance.  I decided to start with a fairly simple new DLL that I have to write in Delphi.  I can make the classes easily enough, but I can not work out how to make the dll interface.

I know that technically the dll interface is not a class, but I was hoping that there would be some other type that I could use.

Appreciate any help

Mathew.
[email protected]

Tjerk

  • EA User
  • **
  • Posts: 231
  • Karma: +1/-0
    • View Profile
Re: Any ideas on a Delphi DLL
« Reply #1 on: March 04, 2003, 11:56:09 pm »
Hi Mathew,

A class can be stereotyped as an interface. When you use such an interface on a diagram, you e.g. have the option to show the interface as a circle or as a class.

You can use "insert element" and then select "interface" as the element type to create an interface in the projectbrowser.

Other way is to create a classdiagram. This way you will see the toolbox selecting the class elements (default on the left side of the screen). There you will find an interface element, drag that one on your diagram and a new interface element is created (both on the diagram as in your projectbrowser!).

Hope this helps,
Tjerk

Mathew Verdouw

  • Guest
Re: Any ideas on a Delphi DLL
« Reply #2 on: March 05, 2003, 11:41:59 am »
Thaks Tjerk,

I did try the second option first (if that makes sense  :) )

If this is the way to define the DLL interface, then the problem is that the code generation for Delphi is not correct.  The resulting code was a class defined as

MAFC = interface (TObject)

with interface and implementation parts.  In Delphi a DLL is a different beast.  Below is an example of a very simple DLL interface.

{------------ Code Snip -----------------}

library Project1;

uses
 SysUtils,
 Classes;

{$R *.res}

function SomeFunction(pSomeVar : pChar) : Integer; stdcall;
begin
  result := 0;
end;

exports
  SomeFunction;

begin
end.

{------------ Code Snip -----------------}

I'd hope that the UML tool/code generation can handle this sort of thing, if not, I'd rather know now so I don'e waste any time looking for it.

I appreciate any further comments.

Mathew
[email protected]

Tjerk

  • EA User
  • **
  • Posts: 231
  • Karma: +1/-0
    • View Profile
Re: Any ideas on a Delphi DLL
« Reply #3 on: March 06, 2003, 12:52:10 am »
Hi Mathew,

I'm not familiar with Delphi, but I have a few questions concerning your interface.
1. An interface should not have any implementation, your example contains implementation (begin...end). Is that the way to do interfaces in Delphi?
2. What is the class in your interface? Methods should be part of a class. If that's not possible in Delphi, I guess Delphi is not really Object Oriented and the interface can then not be discribed in UML.

I hope somebody has experience with Delphi and EA to provide more details.

Greetings,
Tjerk

ufechner

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Any ideas on a Delphi DLL
« Reply #4 on: March 06, 2003, 02:13:31 am »
Hello,

of course delphi supports really object oriented programming.
But if you want to write a dll, that can be used from non-delphi
programms, than you can export procedures and functions only
(unless you use some dirty tricks).
The reason for that is, that there is no cross-language definition
how to export classes from a dll.

Of course you can document the interface of a dll, that does
export functions and procedures, but no classes ;) with
Enterprise Architect. Just use the interface template and define
methods only and no attributes.

But I suppose that this is not UML complient and therefore not
supported by the code-generator.

Regards:

Uwe Fechner