|
|
如题。。
library guilib001;
{$mode objfpc}{$H+}
uses
Classes, interfaces, SysUtils,Forms, guilib001main,// in 'guilib001main.pas',
Global001
{ you can add units after this };
function Comprueba_formulario(formulario:string):Boolean;
Var i:Integer;
begin
Result:=False;
for i := 0 to Screen.CustomFormCount-1 do
if Screen.CustomForms.Name =formulario then
begin
Result:=True;
end
end;
PROCEDURE RunFrmmain001(db: TDBConPak); export;
begin
{$IFDEF MSWINDOWS}
Application.Initialize;
{$ENDIF}
Global001.dbc1:=db;
if not Comprueba_formulario('Formmain001') then
begin
with TFormmain001.Create(Application) do try
ShowModal;
finally
free;
end;
end
else
begin
Formmain001.Show;
end;
end;
{$R *.res}
exports
RunFrmmain001, GetStruct;
begin
end.
/////////////////////////////////////////////////////////////////////////////////////
procedure TMainForm.Button1Click(Sender: TObject);
begin
mDBC.host:=Edit1.Text;
mDBC.user:=Edit2.Text;
mDBC.passwd:=Edit3.Text;
mDBC.port:=SpinEdit1.Value;
mDBC.Protocol:=Edit4.Text;
{$IFDEF MSWINDOWS}
openlibHandle:=LoadLibrary(LibRuta+'guilib001.dll');
{$ELSE}
{$IFDEF DARWIN} //OS X
openlibHandle:=LoadLibrary(LibRuta+'libguilib001.dylib'); // 苹果下没测试
{$ELSE} //Linux
openlibHandle:=LoadLibrary(LibRuta+'libguilib001.so');
{$ENDIF}
{$ENDIF}
if openlibHandle = 0 then
begin
MessageDlg('不能载入动态链接库', mtError, [mbOK], 0);
exit;
end;
try
pointer(RunFrmmain001):=GetProcedureAddress(openlibHandle, 'RunFrmmain001');
if pointer(RunFrmmain001) = nil then
begin
showmessage('在链接库中找不到过程方法!');
exit;
end;
// pointer(RunFrmmain001):=GetProcedureAddress(openlibHandle, 'RunFrmmain001');
pointer(GetStruct):=GetProcedureAddress(openlibHandle, 'GetStruct');
if pointer(GetStruct) = nil then
begin
showmessage('在链接库中找不到程式函数!');
exit;
end;
mp1:=GetStruct();
RunFrmmain001(mDBC);
finally
// FreeLibrary(openlibHandle);
end;
end;
|
|