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的文件、函数和定义的函数。下次再说说调用的一些细节。