当前位置: 代码迷 >> 综合 >> Inno Setup入门(二十七)——使用dll(1)
  详细解决方案

Inno Setup入门(二十七)——使用dll(1)

热度:42   发布时间:2023-11-18 02:57:07.0

Inno Setup入门(二十七)——使用dll(1)

这里讲讲如何调用dll中的函数。先来一个简单的例子:

[code]
var
myPage:TWizardPage;
Button :TNewButton;
Cnt:Integer;
function GetCurrentProcessId(): Integer;
external 'GetCurrentProcessId@C:\Windows\System32\kernel32.dll';procedure ButtonOnClick(Sender: TObject);
beginMsgBox(IntToStr(GetCurrentProcessId()), mbInformation, mb_Ok); end;procedure InitializeWizard();
begin
myPage:=CreateCustomPage(wpWelcome, '标题:自定义页面', '描述:这是我的自定义页面'); 
Button := TNewButton.Create(mypage);
Button.Width := ScaleX(75);
Button.Height := ScaleY(23);
Button.Caption := 'TNewButton';
Button.OnClick := @ButtonOnClick;
Button.Parent := mypage.Surface;
end;

运行效果如下:
在这里插入图片描述
语句:
function GetCurrentProcessId(): Integer;
external ‘GetCurrentProcessId@C:\Windows\System32\kernel32.dll’;
申明了引用dll的文件、函数和定义的函数。下次再说说调用的一些细节。

  相关解决方案