这是调用代码
unit CY;
interface
uses windows;
type
TMember_Rd = Record
iID: integer;
sCode: Array[0..255] of char;
sName: Array[0..255] of char;
end;
PTMember_Rd = ^TMember_Rd;
function GetMember(sStore, sMachine: PChar; const sTrack, sCode, sVerify: PChar;
Member: PTMember_Rd; sError: PChar): Integer; stdcall; external 'Interface.dll';
implementation
end.
我需要调用 GetMember 函数并将数据填充到 Member 中,如果有任何错误,我可以从 sError 获取消息。
我如何调用这个函数?
我不熟悉德尔福;我认为我的错误在于指针。
以下是我的 c# 代码工作
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace JFTest
{
public class JFService
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct PTMember_Rd
{
public Int32 id;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string sCode;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string sName;
}
[DllImport("Interface.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetMember(StringBuilder sStore, StringBuilder sMachine, StringBuilder sTrack, StringBuilder sCode, StringBuilder sVerify, ref PTMember_Rd Member, [MarshalAs(UnmanagedType.LPStr)] string sError);
}
}
而且我没有其他代码,dll是客户发送给我的,他们没有源代码。