첨부된 파일을 델파이에서 사용 하려고 합니다.
lkif.dll 을 어떻게 붙어야 할지 감이 안옵니다.
조언 부탁드립니다.
unit fMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls ;
type
LKIF_FLOATRESULT = (LKIF_FLOATRESULT_VALID, // valid data
LKIF_FLOATRESULT_RANGEOVER_P, // over range at positive (+) side
LKIF_FLOATRESULT_RANGEOVER_N, // over range at negative (-) side
LKIF_FLOATRESULT_WAITING); // comparator result
type LKIF_FLOATVALUE = record
x_FloatResult : LKIF_FLOATRESULT; //' valid or invalid data
x_Value : Double; //' measurement value during LKIF_FLOATRESULT_VALID.
end;
type
TfrmMain = class(TForm)
Label1: TLabel;
lblValue: TLabel;
Button1: TButton;
Timer1: TTimer;
btnSnap: TButton;
btnClose: TButton;
Label2: TLabel;
Label3: TLabel;
procedure FormShow(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnSnapClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
first : LKIF_FLOATRESULT;
second : Extended;
end;
function LKIF_GetCalcData(CalcData1:LKIF_FLOATVALUE;CalcData2:LKIF_FLOATVALUE):longint;stdcall;external 'LkIF.dll';
var
frmMain: TfrmMain;
implementation
procedure Th(FloatResult : LKIF_FLOATRESULT;
Value : Extended); cdecl; external 'LkIF.DLL';
{$R *.dfm}
procedure TfrmMain.btnSnapClick(Sender: TObject);
type TLongIntFunc=function(CalcData1:LKIF_FLOATVALUE;CalcData2:LKIF_FLOATVALUE):longint;stdcall;
var
Th : Thandle;// TLongIntFunc;
Tf : TLongIntFunc;
Tp : TFarProc;
CalcData1 :LKIF_FLOATVALUE;
CalcData2 :LKIF_FLOATVALUE;
begin
Th := LoadLibrary('LkIF.dll');
if Th>0 then
try
Tp := GetProcAddress(Th , PChar('LKIF_GetCalcData'));
if Tp <> nil then
begin
try
Tf := @TLongIntFunc(Tp);
If Tf(CalcData1,CalcData2)=1 Then
If LKIF_GetCalcData(CalcData1,CalcData2)=1 Then
begin
If CalcData1.x_FloatResult=LKIF_FLOATRESULT_VALID Then label2.Caption:=format('''%s''',[CalcData1.x_Value]);
If CalcData2.x_FloatResult=LKIF_FLOATRESULT_VALID Then label3.Caption:=format('''%s''',[CalcData1.x_Value]);
end
Else
showmessage('LKIF_GetCalcData terminated abnormally.');
except
raise ;
end;
end
else
ShowMessage('TestC');
Finally
FreeLibrary(Th);
end
else
ShowMessage('LkIF.dll');
end;
end.
|