DELPHI中动态调用dll
来源:互联网 发布:动易cms安装教程 编辑:程序博客网 时间:2024/05/07 11:09
显式例子:
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, DBTables, DBCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Image1: TImage;
DataSource1: TDataSource;
Table1: TTable;
Table1SpeciesNo: TFloatField;
Table1Category: TStringField;
Table1Common_Name: TStringField;
Table1SpeciesName: TStringField;
Table1Lengthcm: TFloatField;
Table1Length_In: TFloatField;
Table1Notes: TMemoField;
Table1Graphic: TGraphicField;
DBGrid1: TDBGrid;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
// function GetInteger(I:Integer): Integer;stdcall;external 'DLLOne.dll';
// function GetDouble(F:Double): Double;stdcall;external 'DLLOne.dll';
TGetDouble = function (F:Double): Double; stdcall;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var D: Double;
DLLHandle: THandle;
Func: TGetDouble;
begin
Image1.Picture.Assign(Table1Graphic);
Table1Graphic.Assign(Image1.Picture);
Exit;
DLLHandle := LoadLibrary('DLLOne.dll');
try
@Func := GetProcAddress(DLLHandle, 'GetDouble');
//Edit1.Text := IntToStr(GetInteger(2));
//D := GetDouble(2.2);
if Assigned(@Func) then
begin
D := Func(2.2);
Edit2.Text := FloatToStr(D);
end;
finally
FreeLibrary(DLLHandle);
end;
end;
end.
隐式例子:
library DLLOne;
uses
SysUtils,
Classes;
{$R *.res}
function GetDoubleExt(F:Double): Double;stdcall;external 'DLLTwo.dll';
function GetInt(I:Integer): Integer;stdcall;external 'DLLTwo.dll';
function GetInteger(I:Integer): Integer;stdcall;
begin
Result := GetInt(I);
end;
function GetDouble(D:Double): Double;stdcall;
begin
Result := GetDoubleExt(D);
end;
exports
GetInteger,
GetDouble;
begin
end.
library DLLTwo;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes;
{$R *.res}
function GetDoubleExt(D:Double):Double ;stdcall;
begin
Result := D;
end;
function GetInt(I:Integer): Integer;stdcall;
begin
Result := I;
end;
exports
GetDoubleExt,
GetInt;
begin
end.
- DELPHI中动态调用dll
- Delphi中动态调用DLL的方法
- Delphi中动态调用DLL的方法
- delphi 动态调用DLL
- delphi 动态调用dll例子
- delphi动态调用dll窗体
- DELPHI中动态调用DLL的载入片断代码
- 在Delphi中动态调用C++的DLL
- 在Delphi中调用DLL
- DELPHI中创建调用DLL
- Delphi 动态与静态调用DLL
- Delphi 动态与静态调用DLL
- Delphi动态调用C++写的DLL
- Delphi调用C# 编写dll动态库
- 在Delphi中怎样调用立象(Argox)条码打印机动态库PPLA/PPLB(DLL)
- delphi dll 静态调用和动态调用方法总结
- Delphi 类库(DLL)动态调用与静态调用示例讲解
- Java中调用Delphi编写的DLL
- Java记事本和界面(一)
- C#中使用SendMessage
- Oracle 9i无法调用ODBC数据源
- .Net Remoting小心
- asp调用存储过程
- DELPHI中动态调用dll
- PHP中静态页处理动态内容的思路
- VB我来也
- 一次TempDB损毁的处理过程
- Good site on Interview
- Oracle PL/SQL入门之案例实践(转)
- 系统软件
- 小技巧:警告框里的文字换行
- J2SE:JAVA泛型