动态链接库(Dynamic Link Library)是一个可以执行的并可以被多个Windows应用程序共享的程序模块(Module)。模块中包含代码、数据和资源。
  动态链接库的优点:不用重复编译和链接,一旦装入内存,DLL中的函数就可以被系统中的任何在运行的应用程序使用,而不必产生函数的多个COPY。
  DLL和EXE很类似,区别在于,DLL文件中虽然包含了可执行代码却不能单独执行,只能由Windows应用程序直接或间接调用。

  静态链接是将应用程序调用的库函数COPY一份到应用程序中去。
  动态链接,当应用程序使用了某个DLL中的函数时,动态链接不COPY代码,还是在运行期间在DLL的位置寻找所需的函数代码。

第一种方法:

生动DLL,不能直接行运,在prjoect里按complie,或者按ctrl + F9编译运行,将生成的DLL,复制到新项目中用。

uses
SysUtils,
Classes; {$R *.res} function Max(x,y,z:Integer):Integer;stdcall;
var
t:Integer;
begin
if (x<y) then
t := y;
else
t := x; if (t<z) then
t := z; Result := t;
end; begin end.

测试调用运行:

var
Form1: TForm1;
function Max(x,y,z:Integer):Integer;stdcall;external 'ProjectMax.dll'; implementation {$R *.dfm} procedure TForm1.btn1Click(Sender: TObject);
var
t: Integer;
begin
t := Max(,,);
ShowMessage(IntToStr(t));
end;

动态调用DLL

type
Max = function(x,y,z:integer):integer; stdCall; procedure TForm1.btn1Click(Sender: TObject);
var
temp: Integer;
handle: THandle;
FPointer: TFarProc;
MyFunc: Max;
begin handle := LoadLibrary('ProjectMaxDll.dll');
if handle <> then
begin
FPointer := GetProcAddress(handle,'Max');
if FPointer<>nil then
begin
MyFunc:= Max(FPointer);
temp:= MyFunc(,,);
ShowMessage(IntToStr(temp));
end
else
begin end
end
else
ShowMessage('未找到动态链接库!'); end;

Delphi- DLL操作的更多相关文章

  1. Delphi中的dll操作

    利用delphi dll wizard进行dll的编写. 创建:保存时改dll名称 library test2; uses SysUtils, Classes, forms, dialogs; {$R ...

  2. Delphi摄像头操作

    /*Title:Delphi摄像头操作 *Author:Insun *Blog:http://yxmhero1989.blog.163.com *From:www.4safer.com */ 为了笔耕 ...

  3. delphi dll调用问题

    dll传递string实现方法 delphi中dll传递string的实现方法: dll项目uses第一个引用sharemem单元; 调用的项目uses第一个引用sharemem单元; 调用的单元us ...

  4. 在.net中调用Delphi dll的Pchar转换

    Pchar是非托管代码,要在.net中调用Delphi dll中的功能,请使用MarshalAs属性告知.net调用PInvoke去转换.net中标准的string类型.如果Delphi dll是De ...

  5. Delphi Excel 操作大全

    Delphi Excel 操作大全 (一) 使用动态创建的方法首先创建 Excel 对象,使用ComObj:var ExcelApp: Variant;ExcelApp := CreateOleObj ...

  6. delphi 换行操作 Word

    delphi 换行操作 我将我的商用<旅行社管理系统>的 发团通知 部分奉献给您,望对您有所帮助. procedure TFrmMain.N327Click(Sender: TObject ...

  7. Delphi内存操作API函数(备查,并一一学习)

    Delphi内存操作API函数System.IsMemoryManagerSet;System.Move;System.New;System.ReallocMem;System.ReallocMemo ...

  8. Delphi Dll 动态调用例子(3)-仔细看一下

    http://blog.163.com/bxf_0011/blog/static/35420330200952075114318/ Delphi 动态链接库的动态和静态调用 为了让人能快速的理解 静态 ...

  9. C# 调用Delphi dll

    delphi dll 源码: library dllres; type char10 = ..] of char; TMydata = packed record id: Integer; name: ...

  10. Borland.Delphi.dll

    Borland.Delphi.dll Borland Delphi Runtime for .NET Imports Borland.DelphiImports Borland.Delphi.Unit ...

随机推荐

  1. Linux下 config/configure/Configure、make 、make test/make check、sudo make install 的作用

    转自Linux下 config/configure/Configure.make .make test/make check.sudo make install 的作用 这些都是典型的使用GNU的AU ...

  2. Firefly框架参考

    在游戏服务器端,往往需要处理大量的各种各样的任务,每一项任务所需的系统资源也可能不同.而这些复杂的任务只用一个单独的服务器进程是很难支撑和管理起来的.所以,游戏服务器端的开发者往往需要花费大量的时间精 ...

  3. Error -27791: Server xx has shut down the connection prematurely

    最近在进行一次性能测试中遇到一个问题,并发较大的时候会出现LR出现Error -27791: Server xx has shut down the connection prematurely的ER ...

  4. 很受欢迎的Linux笔记(短小精悍)

    http://blog.csdn.net/xsl1990/article/details/8274028 如何知道所使用的LINUX是哪个发行版? lsb_release -a 查找某个文件的另类方法 ...

  5. javaweb学习总结(三十三)——使用JDBC对数据库进行CRUD

    一.statement对象介绍 Jdbc中的statement对象用于向数据库发送SQL语句,想完成对数据库的增删改查,只需要通过这个对象向数据库发送增删改查语句即可. Statement对象的exe ...

  6. Android Button悬浮在SurfaceView上

    实现Button悬浮于与SurfaceView之上实现 注意:你实现的SurfaceView和android中的Button,EditView是同级的,不能把一个包含在另一个里面 1.创建自己的Sur ...

  7. (转载)NET流操作

    http://www.oseye.net/user/kevin/blog/86 概念 数据流(Stream)是对串行传输数据的一种抽象表示,是对输入/输出的一种抽象.数据有来源和目的地,衔接两者的就是 ...

  8. Ember.js demo6

    <!DOCTYPE html> <html> <head> <meta name="description" content=" ...

  9. 企业2.0杀出一号种子选手 “Linkwedo”横空出世

    当下,最热门的话题就是企业2.0和1.0的新老交替,在过去的时间里OA在国内几乎是企业1.0的代名词,各大知名OA厂商一直占领着国内的企业市场,但企业2.0在全球越演越烈,甚至大有替代企业1.0的的迹 ...

  10. Binary to Text (ASCII) Conversion

    Binary to Text (ASCII) Conversion Description: Write a function that takes in a binary string and re ...