delphi dll 静态调用和动态调用方法总结
dll 调用方法有 静态调用和动态调用两种方法
用到的dll为上篇文章所编写的dll.
总结如下:
Unit Unit1;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
Type
TForm1 = Class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Procedure Button1Click(Sender: TObject);
Procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
End;
Var
Form1: TForm1;
Implementation
Function Min(X, Y: Integer): Integer; external 'Project1.dll';
Function Max(X, Y: Integer): Integer; external 'Project1.dll';
procedure SynAPP(App:THandle);stdcall;external 'Project1.dll'; //这里的
procedure ShowForm;stdcall;external 'Project1.dll';
procedure showmyform;stdcall;external 'Project1.dll';
{$R *.dfm}
Procedure TForm1.Button1Click(Sender: TObject);
Begin
showmessage(inttostr(Min(1, 100)));//静态方法
showmessage(inttostr(Max(1, 100)));//静态方法
End;
//动态方法
Procedure TForm1.Button2Click(Sender: TObject);
Type
Tmax = Function(X, Y: Integer): Integer;
THandle = Integer;
Var
mymax: Tmax;
Handle: THandle;
Begin
Handle := LoadLibrary('Project1.dll');
@mymax := GetProcAddress(Handle, 'Max');
showmessage(inttostr(mymax(1, 100)));
FreeLibrary(Handle);
End;
procedure TForm1.Button3Click(Sender: TObject);
begin
// SynAPP(Application.Handle);
showmyform ;//静态方法
//ShowForm ;
end;
End.
相关文档:
unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class
(TForm)
Button1: TButton;
Button2: TButton;
procedure
Button1Click(Sender: TObject);
procedure
Button2Click(Sender: TObj ......
我使用delphi也不是很长时间,由于经常要用到SQL语句,总结了一些Delphi中使用SQL语句要注意的事项,归纳起来主要有一下几条:
一、空格不要漏:
我们经常要拼装SQL语句,特别是where条件句,在各个语句中别忘了头尾加上空格。因为在一个语句中我们会注意用空格分开关键字但是往往忘了头尾的空格。例如:
sSQL=' select ......
JNI(Java+Native+Interface,Java本地接口)技术大家都不陌生,它可以帮助解决Java访问底层硬件的局限和执行效率的提高。关于JNI的开发,大多数资料讨论的都是如何用C/C++语言开发JNI,甚至于JDK也提供了一个javah工具来自动生成C语言程序框架。但是,对于广大的Delphi程序员来说,难道就不能用自己喜爱的Delphi与Java互通消 ......
转自:http://www.52delphi.com/List.asp?ID=597&Page=1
核心提示:函数需要 uses Direct3D9,D3DX9; 偶然发现一个函数可以直接保存表面到文件1!所以修改了一下,函数为:...
procedure CaptureScreen(Const FileName: string);
var
BitsPerPixel: Byte;
pD3D: IDirect3D9;
pSurface: IDirect3DSurface9;
......
Delphi字符串函数大全
uses StrUtils;
【字符串函数大全】
首部 function AnsiResemblesText(const AText, AOther: string): Boolean;
$[StrUtils.pas
功能 返回两个字符串是否相似
  ......