Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distributing Classes

Status
Not open for further replies.

Glenn9999

Programmer
Jun 19, 2004
2,311
US
One of the questions I've been looking into is the ability to distribute class code in a portable way. I got a sample going within a DLL with a regular class (export create and destroy), and an interface (just create, no worries about scope). But I was wondering what the general best practice is on such things, so there are no unforeseen problems, and especially what will work in multiple languages? Do I need to investigate ActiveX on this, or is what I'm doing fine?

 
Your method is one way, another method is to use runtime packages.
I would stick with interfaces as they are easier to work (and easier interop) with.

/Daddy

-----------------------------------------------------
Helping people is my job...
 
> I would stick with interfaces as they are easier to work (and easier interop) with.

One more question on this, since I'm not finding a page (or don't know the terms to look for): How do I set up the DLL so it can be imported into Delphi and a interface unit (e.g. "mydll_tlb.pas") can be generated?

 
Glenn9999 said:
One more question on this, since I'm not finding a page (or don't know the terms to look for): How do I set up the DLL so it can be imported into Delphi and a interface unit (e.g. "mydll_tlb.pas") can be generated?

It is called an ActiveX library :)

/Daddy

-----------------------------------------------------
Helping people is my job...
 
Which means either I'm doing something wrong or the type library editor and so forth isn't working correctly.

At least I know I'm on the right track.

 
And...it's the latter ("Class not registered", despite me doing it several ways and times). I understand it's common with the 64-bit Windows OSes. Worth looking into, at least for the educational aspect of it.

 
if you are on a 64 bit system, make sure you are using regsvr32 from the %windir%\SysWoW64 directory.
What IDE are you using?

/Daddy

-----------------------------------------------------
Helping people is my job...
 
I am and it claims the DLL is registered. The Delphi 3 IDE claims the same thing using the Register button on the type library screen (still on that, really can't afford anything newer). Still the same problems:

1. DLL imports, and no entry shows up. No message or anything like that.
2. Running a program that calls the interface produces EOleSysError "Class Not Registered".

Code as called. The unit is being used that is generated along with the type library in this project.

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  a: IMyInterface;
begin
  a := CoCoMyInterface.Create;
  a.DoIt;
end;

 
Delphi3??

that IDE will not register your class correctly under Win64.

/Daddy

-----------------------------------------------------
Helping people is my job...
 
Will Turbo Delphi 2006 do it, or is it too stripped down? FWIW, tried it there, same result.

 
Have you looked at Lazarus (it is free and comes with the Free Pascal Compiler)?

I don't know whether or not it will do what you want, but I believe that it is relatively up to date and I think it can convert most (especially older) Delphi files and projects into Lazarus format. If you do look into it I would suggest working on a copy of your Delphi files just in case it modifies them during conversion instead of creating copies of them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top