Delphi项目组,引用一个项目
大家好
我是Delphi的新手.使用RAD Studio XE.我已经习惯了Visual Studio.
我创建了一个项目组并添加了一个第三方库.我创建了一个带有GUI的新项目进行实验.
我只是想知道如何将GUI项目中的引用添加到Library项目中?在Visual Studio中,您将单击添加引用"并找到被引用的项目.
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.
Delphi项目组"的概念类似于Visual Studio解决方案.
如果您使用Delphi而不是Delphi Prizm,则意味着您不是在开发.NET程序集,而是在开发本机Windows代码.对于本机Windows,没有汇编的概念,也没有引用的概念.
不幸的是,您只能使用不太强大的 exporting 和 importing 方法的低级概念,它们甚至都不是面向对象的. (您可以通过显式传递自我"参数来模拟非常基本的面向对象的功能,但这是一项高级技术,需要对OOP内部有很好的了解.)您还可以使用 package 的Delphi概念从技术上讲,它是基于本机导入/导出的,但在思想上与.NET接近(Delphi是主要的.NET的前身).但是软件包在Delphi项目之间.让我们谈谈在Delphi中使用本机DLL.使用external
关键字在源代码中执行导入.
这是一个简单的示例:
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 usingexternal
key word.
Here is a simple example:
procedure DllMessage; external 'SimpleMessageDLL.dll';
在此处找到完整的代码示例:
http://delphi.about.com/od/windowsshellapi/a/dll_basics.htm [ ^ ].
或者,您可以在运行时使用Windows API LoadLibrary
/LoadLibraryEx
加载DLL,并使用GetProcAddress
访问DLL方法.参见:
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 [
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[^].