动态链接库(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. How to Run Node.js with Express on Mobile Devices

    We released a JXcore plugin for Apache Cordova recently and in this article I will show how to run a ...

  2. icon在线编辑和查找工具

    1.www.iconpng.com 2.在线编辑http://www.ico.la/ 3.小图标查找 http://icomoon.io/app/ 4.20个免费的psd http://www.osc ...

  3. 项目管理系统 SQL2005数据库查询CPU100%问题研究

    [一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4595084.html]  在项目管理系统中出现查询工程明细出现CPU100%卡死症状: 1.打 ...

  4. [转贴]超级懒汉编写的基于.NET的微信SDK

    一.前言 特别不喜欢麻烦的一个人,最近碰到了微信开发.下载下来了一些其他人写的微信开发“框架”,但是被恶心到了,实现的太臃肿啦. 最不喜欢的就是把微信返回的xml消息在组装成实体类,所以会比较臃肿,现 ...

  5. ThinkPHP3.2.3验证码显示、刷新、校验

    显示验证码 首先在Home/Controller下创建一个公共控制器PublicController <?php namespace Home\Controller; use Think\Con ...

  6. Ember.js demo2

    <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1 ...

  7. java数组或集合返回空的问题

    在有返回值的情况下,平时我写代码基本遇到错误什么都是返回null,我因为我觉得把数组或集合这个初始化占空间. 但是我发现这样在每次客户段调用都要进行非空判断,而且有时调用内置api还容易报错误,于是解 ...

  8. 【HDOJ】1022 Train Problem I

    栈和队列训练题目. #include <stdio.h> #include <string.h> #define MAXNUM 1005 char in[MAXNUM]; ch ...

  9. Webform——验证控件

    验证控件一般是在注册的时候用到,是直接将JS代码封装到了控件里面,拉过来直接可以用,下面介绍一下主要用法: 1.CompareValidator:比较验证 常用属性:ControlToCompare ...

  10. Windows下的.NET+ Memcached安装

    转载请标明出处: http://www.yaosansi.com/ 原文:http://www.yaosansi.com/post/1396.html Memcached官方:http://danga ...