TShowPerSN = function (AHandle: THandle; ACaption: String): BOOL; StdCall;
EDLLLoadError = class(Exception);//同时分创建一个出错记录类
// 1 -------------------------------
TMAINCLTR = class(TForm) //这里不变,系统自动生成
procedure TMAINCLTR.ToolButton1Click(Sender: TObject);
var //按钮的调用事件:调用过程
LibHandle: THandle;
ShowPerSN: TShowPerSN;
begin
Application.Title:=''人力资源管理系统DLL文件测试程式'';
{ Attempt to load the DLL 尝试装入DLL文件}
LibHandle := LoadLibrary(''MGRPERSN.DLL'');
try
if LibHandle = 0 then
raise EDLLLoadError.Create(''Unable to Load DLL(无法成功装入MGRPERSN.DLL)'');
@ShowPerSN := GetProcAddress(LibHandle, ''ShowPerSN'');
if not (@ShowPerSN = nil) then
ShowPerSN(Application.Handle, ''人事
资料管理'')//呼叫出窗体
else
RaiseLastWin32Error;
finally
FreeLibrary(LibHandle); // Unload the DLL.
end;
end;
============== END ==================