Delphi- DLL操作
动态链接库(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操作的更多相关文章
- Delphi中的dll操作
利用delphi dll wizard进行dll的编写. 创建:保存时改dll名称 library test2; uses SysUtils, Classes, forms, dialogs; {$R ...
- Delphi摄像头操作
/*Title:Delphi摄像头操作 *Author:Insun *Blog:http://yxmhero1989.blog.163.com *From:www.4safer.com */ 为了笔耕 ...
- delphi dll调用问题
dll传递string实现方法 delphi中dll传递string的实现方法: dll项目uses第一个引用sharemem单元; 调用的项目uses第一个引用sharemem单元; 调用的单元us ...
- 在.net中调用Delphi dll的Pchar转换
Pchar是非托管代码,要在.net中调用Delphi dll中的功能,请使用MarshalAs属性告知.net调用PInvoke去转换.net中标准的string类型.如果Delphi dll是De ...
- Delphi Excel 操作大全
Delphi Excel 操作大全 (一) 使用动态创建的方法首先创建 Excel 对象,使用ComObj:var ExcelApp: Variant;ExcelApp := CreateOleObj ...
- delphi 换行操作 Word
delphi 换行操作 我将我的商用<旅行社管理系统>的 发团通知 部分奉献给您,望对您有所帮助. procedure TFrmMain.N327Click(Sender: TObject ...
- Delphi内存操作API函数(备查,并一一学习)
Delphi内存操作API函数System.IsMemoryManagerSet;System.Move;System.New;System.ReallocMem;System.ReallocMemo ...
- Delphi Dll 动态调用例子(3)-仔细看一下
http://blog.163.com/bxf_0011/blog/static/35420330200952075114318/ Delphi 动态链接库的动态和静态调用 为了让人能快速的理解 静态 ...
- C# 调用Delphi dll
delphi dll 源码: library dllres; type char10 = ..] of char; TMydata = packed record id: Integer; name: ...
- Borland.Delphi.dll
Borland.Delphi.dll Borland Delphi Runtime for .NET Imports Borland.DelphiImports Borland.Delphi.Unit ...
随机推荐
- css 多行显示省略号....
CSS属性如下: white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
- java常见内存溢出(OOM)
jvm内存区域 程序计数器一块很小的内存空间,作用是当前线程所执行的字节码的行号指示器. java栈与程序计数器一样,java栈(虚拟机栈)也是线程私有的,其生命周期与线程相同.通常存放基本数据类型, ...
- SecureCRT 中文乱码问题
1.修改远程linux机器的配置 [root@rhel ~]#vi /etc/sysconfig/i18n 把LANG改成支持UTF-8的字符集 如: LANG=”zh_CN.UTF-8″ 或者是 L ...
- [jobdu]数组中出现次数超过一半的数字
找到以后要再扫一遍确认. http://zhedahht.blog.163.com/blog/static/25411174201085114733349/ #include <iostream ...
- 获取C#中exe程序的实例名
获取sanjiao.frmsanjiao string strPass = @"D:\WinAutoTest\sanjiao.exe"; Assembly assebly = As ...
- asp.net控件(1)Repeater
1. 通过Repeater和数据源创建表格 <AlternatingItemTemplate>属性可以控制单元格交替显示不同的背景颜色 <table width=" sty ...
- SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-001- DispatcherServlet的高级配置(ServletRegistration.Dynamic、WebApplicationInitializer)
一. 1.如想在DispatcherServlet在Servlet容器中注册后自定义一些操作,如开启文件上传功能,则可重写通过AbstractAnnotationConfigDispatcherSer ...
- 查看wtmp文件内容
1./var/log/wtmp文件的作用 /var/log/wtmp也是一个二进制文件,记录每个用户的登录次数和持续时间等信息! 2.查看方法:可以用last命令输出当中内容 1 2 3 ...
- 使用C#在word中插入页眉页脚
//插入页脚 public void InsertFooter(string footer) { if (ActiveWindow.ActivePane.View.Type == WdViewType ...
- BZOJ_2179_FFT快速傅立叶_(FFT)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=2179 超大整数乘法 分析 FFT模板题. 把数字看成是多项式,x是10.然后用FFT做多项式乘 ...