Delphi调用Dll的的2种写法
2014-07-29 17:47
405 查看
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; //定义类型要与原函数一样 function GetUserDefaultUILanguage():Integer;external 'Kernel32.DLL'; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if GetUserDefaultUILanguage() = $0804 then begin Caption:='简体中文'; end else begin Caption:='英文'; end; end; //方法2 使用LoadLibrary procedure TForm1.Button2Click(Sender: TObject); var h:THandle; pFunc:function():Integer;stdcall; begin h:=LoadLibrary(PChar('Kernel32.DLL')); if h=0 then Exit; pFunc:= GetProcAddress(h,PChar('GetUserDefaultUILanguage')); if Assigned(pFunc) then if pFunc() = $0804 then begin Caption:='简体中文'; end else begin Caption:='英文'; end; FreeLibrary(h); end;procedure TForm1.Button3Click(Sender: TObject); var h:THandle; pFunc:function():Integer;stdcall; begin h:=LoadLibrary('Kernel32.DLL'); if h=0 then Exit; @pFunc:= GetProcAddress(h,'GetUserDefaultUILanguage'); if Assigned(pFunc) then if pFunc() = $0804 then begin Caption:='CHS'; end else begin Caption:='ENGLISH'; end; FreeLibrary(h); end;
end.
来自为知笔记(Wiz)
附件列表
相关文章推荐
- 黄聪:关于delphi Com+调用C# DLL的一点说明[转]
- Delphi调用VC++6.0编写的Dll
- Delphi中编写DLL调用子窗口
- 三种语言对Delphi的dll的调用
- delphi调用vc编写的DLL应注意的问题
- C#的DLL注册为COM,Delphi来调用
- Delphi 调用C dll
- Delphi中调用VC编写的DLL内对象
- C#调用Delphi编写的Dll,实现绘图的功能
- VC调用Delphi的DLL时遇到的问题及解决
- Delphi调用C# 编写dll动态库
- Delphi中的DLL封装和调用对象编写碰到的问题
- VC调用DELPHI DLL
- VC6动态调用DELPHI DLL
- Delphi中调用DLL(Windows API)清空回收站
- Delphi中高级DLL的编写和调用技巧
- Delphi下DLL调用以及共享数据库连接
- delphi调用vc编写的DLL应注意的问题
- 一个DELPHI程序要调用DLL,而DLL中的函数名,参数个数,参数类型为不定
- Delphi调用C#dll的问题