动态链接库(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. 关于Windows环境下安装Android模拟器Genymotion的教程

    打开Genymotion的官网www.genymotion.com,点击按钮"get genymotion", 选择"Free"下的"DOWNLOAD ...

  2. [topcoder]TallPeople

    水题.http://community.topcoder.com/stat?c=problem_statement&pm=2923&rd=5854 一开始错了是因为理解错题意.还有就是 ...

  3. .Net remoting, Webservice,WCF,Socket区别

    传统上,我们把计算机后台程序(Daemon)提供的功能,称为"服务"(service).比如,让一个杀毒软件在后台运行,它会自动监控系统,那么这种自动监控就是一个"服务& ...

  4. YII CJson类

    CJson文档: http://www.yiiframework.com/doc/api/1.1/CJSON CJson::encode可以编码任何类型的数据:源码如下: public static ...

  5. OSFM Tables

    OSFM - Oracle Shop Floor Management 1. (N) Shop Floor Manager > Lot Based Jobs (B: New) Status: U ...

  6. hdu4374One hundred layer (DP+单调队列)

    http://acm.hdu.edu.cn/showproblem.php?pid=4374 去年多校的题 今年才做 不知道这一年都干嘛去了.. DP的思路很好想 dp[i][j] = max(dp[ ...

  7. -fembed-bitcode is not supported on versions of iOS prior to 6.0 问题修复

    参考一下网址 http://stackoverflow.com/questions/30867544/fembed-bitcode-is-not-supported-on-versions-of-io ...

  8. 【转】Mac不能复制拷贝写入文件到移动硬盘,U盘怎么办 |

    原文网址:http://jingyan.baidu.com/article/a3aad71aa1dde7b1fb0096ab.html 有的小伙伴把移动硬盘或 U 盘接入到 Mac 电脑上,当把文件拷 ...

  9. js循环array,json,map

    var str = '[{"uname":"王强","day":"2010/06/17"},{"uname&q ...

  10. ruby编程语言-学习笔记1

    安装完 ruby ri irb ruby-devel 1. 先来个简单的,写个helloworld  给新手们 (terminal中,# 代表root权限,$ 代表用户权限, 前面的就不写了.) # ...