Y
yxzymh
Unregistered / Unconfirmed
GUEST, unregistred user!
调用C编写的DLL,C中定义如下:
typedef void __stdcall (*fun_AddResult)(char pDataStr[10][255],double pDataDouble[100]);
extern "C"
void __declspec(dllimport) __stdcall SetBackColor(TColor pBkColor);
extern "C"
void __declspec(dllimport) __stdcall FanSelect(
void *pSNames,
const int pSNameCount,
void *pSubSNames,
const int pSubSNameCount,
const double &pF,
const int &pFUnitType,
const double &pP,
const int &pPUnitType,
fun_AddResult pAddResult//函数指针,用于回传数据
);
看我编写的调用:
unit GlobalVar;
interface
Uses
Dialogs,SysUtils;
type
TCharArray=array [0..9] Of Array [0..254] of Char;
pCharArray=^TCharArray;
TDoubleArray=array [0..99] of Double;
pDoubleArray=^TDoubleArray;
fun_AddResult=Procedure(pDataStr:TCharArray;pDataDouble:TDoubleArray);StdCall;
Var
Result1 : TCharArray;
Result2 : TDoubleArray;
Procedure FanSelect(pSNames : Pchar;pSNameCount : Integer;
pSubSNames : Pchar;pSubSNameCount : Integer;
pF : PDouble;pFUnitType : PInteger;
pP : PDouble;pPUnitType : PInteger
pAddResult : fun_AddResult);StdCall;External 'LMES.dll';
Procedure MyProc(pDataStr:TCharArray;pDataDouble:TDoubleArray);StdCall;
Procedure GetFanSelectInfo();
implementation
Procedure MyProc(pDataStr:TCharArray;pDataDouble:TDoubleArray);StdCall;
Begin
pDataStr := Result1;
pDataDouble := Result2;
End;
Procedure GetFanSelectInfo();
Var
SNames,SubSNameS : Pointer;
ResultS : Fun_AddResult;
Result1 : TCharArray;
Result2 : TDoubleArray;
pF,pP : PDouble;
pFUnitType,pPUnitType : PInteger;
begin
SNames := Pchar('SYT');
SubSNameS := Pchar('L');
New(pF);
New(pFUnitType);
New(pP);
New(pPUnitType);
pF^ := 9837;
pFUnitType^ := 0;
pP^ := 750;
pPUnitType^ := 0
ResultS := MyProc;
FanSelect(SNames,1,SubSNameS,1,pF,pFUnitType,pP,
pPUnitType,ResultS);
ShowMessage(Result1[1]);
ShowMessage(FloatToStr(Result2[1]))
End;
end.
为何数据未能回传呢?还是我传递参数的方法不对?(Dll肯定没有问题)请各位大师帮忙解决下哈!
typedef void __stdcall (*fun_AddResult)(char pDataStr[10][255],double pDataDouble[100]);
extern "C"
void __declspec(dllimport) __stdcall SetBackColor(TColor pBkColor);
extern "C"
void __declspec(dllimport) __stdcall FanSelect(
void *pSNames,
const int pSNameCount,
void *pSubSNames,
const int pSubSNameCount,
const double &pF,
const int &pFUnitType,
const double &pP,
const int &pPUnitType,
fun_AddResult pAddResult//函数指针,用于回传数据
);
看我编写的调用:
unit GlobalVar;
interface
Uses
Dialogs,SysUtils;
type
TCharArray=array [0..9] Of Array [0..254] of Char;
pCharArray=^TCharArray;
TDoubleArray=array [0..99] of Double;
pDoubleArray=^TDoubleArray;
fun_AddResult=Procedure(pDataStr:TCharArray;pDataDouble:TDoubleArray);StdCall;
Var
Result1 : TCharArray;
Result2 : TDoubleArray;
Procedure FanSelect(pSNames : Pchar;pSNameCount : Integer;
pSubSNames : Pchar;pSubSNameCount : Integer;
pF : PDouble;pFUnitType : PInteger;
pP : PDouble;pPUnitType : PInteger
pAddResult : fun_AddResult);StdCall;External 'LMES.dll';
Procedure MyProc(pDataStr:TCharArray;pDataDouble:TDoubleArray);StdCall;
Procedure GetFanSelectInfo();
implementation
Procedure MyProc(pDataStr:TCharArray;pDataDouble:TDoubleArray);StdCall;
Begin
pDataStr := Result1;
pDataDouble := Result2;
End;
Procedure GetFanSelectInfo();
Var
SNames,SubSNameS : Pointer;
ResultS : Fun_AddResult;
Result1 : TCharArray;
Result2 : TDoubleArray;
pF,pP : PDouble;
pFUnitType,pPUnitType : PInteger;
begin
SNames := Pchar('SYT');
SubSNameS := Pchar('L');
New(pF);
New(pFUnitType);
New(pP);
New(pPUnitType);
pF^ := 9837;
pFUnitType^ := 0;
pP^ := 750;
pPUnitType^ := 0
ResultS := MyProc;
FanSelect(SNames,1,SubSNameS,1,pF,pFUnitType,pP,
pPUnitType,ResultS);
ShowMessage(Result1[1]);
ShowMessage(FloatToStr(Result2[1]))
End;
end.
为何数据未能回传呢?还是我传递参数的方法不对?(Dll肯定没有问题)请各位大师帮忙解决下哈!