Click here to Skip to main content
16,015,583 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I'm a complete newby to Delphi. Using RAD Studio XE. I am used to Visual Studio.

I created a project group and added a third party library. I created a new project with a GUI for experimenting.

I am just wondering how to add a reference from my GUI project to the Library project? In visual studio, you'd click "Add Reference" and find the referenced project.
Posted

1 solution

Delphi "Project group" is the concept similar to Visual Studio Solution.

If you use Delphi and not Delphi Prizm, it means you're not developing .NET assemblies but you're developing native Windows code. For native Windows, there is no a concept of assembly and there is no a concept of references.

Unfortunately, you can use only less robust lower-level concept of exporting and importing methods, which are not even object-oriented. (You can simulate very basic object-oriented features via explicit passing of "self" parameters, but this is an advanced technique which requires good understanding of OOP internals.) You can also use Delphi concept of package which is technically based on native import/export but ideologically close to .NET (Delphi is a major .NET predecessor). But packages are between Delphi projects. Let's talk about consuming native DLL in Delphi. Import is performed in source code using external key word.

Here is a simple example:

Pascal
procedure DllMessage; external 'SimpleMessageDLL.dll';


Find a full code sample here:
http://delphi.about.com/od/windowsshellapi/a/dll_basics.htm[^].

Alternatively, you can load a DLL during run-time using Windows API LoadLibrary/LoadLibraryEx and access DLL methods using GetProcAddress. See:
http://msdn.microsoft.com/en-us/library/ms684175(v=vs.85).aspx[^],
http://msdn.microsoft.com/en-us/library/ms684179(v=vs.85).aspx[^],
http://msdn.microsoft.com/en-us/library/ms683212(v=vs.85).aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900