关于调用delphi写的DLL的问题,纠结啊
delphi的接口方法是这样的:
procedure GetLastCashCardBalance(Card:PTMemberCashCard_Rd);stdcall;
begin
Card.iMemberID := FPosService.LastCashCardBalance.iMemberID;
SetPChar(@Card.sMemberCode[0], FPosService.LastCashCardBalance.sMemberCode);
DateTimeToSystemTime(FPosService.LastCashCardBalance.dateValid,Card.dateValid);
Card.mBalance := FPosService.LastCashCardBalance.mBalance;
Card.mBottom := FPosService.LastCashCardBalance.mBottom;
Card.mAmount := FPosService.LastCashCardBalance.mAmount;
end;
其中PTMemberCashCard_Rd是这么定义的
{ TMemberCashCard = class
iMemberID: integer;
sMemberCode: string;
dateValid: TDate;
mBalance: TMoney;
mBottom: TMoney;
mAmount: TMoney;
bRecycle: boolean;
public
procedure Clear;
end; }
TMemberCashCard_Rd = Record
iMemberID: integer;
sMemberCode: Array[0..255] of char;
dateValid: SystemTime;
mBalance: integer;
mBottom: integer;
mAmount: integer;
bRecycle: Integer;
end;
PTMemberCashCard_Rd =^TMemberCashCard_Rd;
我在C#里的调用方法如下
定义结构
public struct LastCashCardBalance
{
public Int32 iMemberID;
public string sMemberCode;
public DateTime dateValid;
public Int32 mBalance;
public Int32 mBottom;
public Int32 mAmount;
public Int32 bRecycle;
}
[DllImport("CardInterface.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern void GetLastCashCardBalance( LastCashCardBalance s);