C#调用Delphi DLL里的函数参数如何传啊 5
functionGetSoftDogData(myuid:Integer;TestCode:PChar):byte;stdcall;//方法Delphi函数结构vardo...
function GetSoftDogData(myuid:Integer;TestCode :PChar):byte;stdcall; //方法
Delphi 函数结构
var dognum :byte ;
SoftDogData :PSoftDogData;
myuid :integer;
begin
///其中SoftDogData是个指针,指向一个下面的结构体 new(SoftDogData);
myuid :=24825159;
if GetSoftDogData(myuid,PChar(SoftDogData))>0 then
begin
EditData0.Text :=StrPas(SoftDogData.data0);
EditData1.Text :=StrPas(SoftDogData.data1);
EditData2.Text :=StrPas(SoftDogData.data2);
EditData3.Text :=StrPas(SoftDogData.data3);
EditData4.Text :=StrPas(SoftDogData.data4);
exit;
end;
TSoftDogData =record
data0 :array [0..511] of char; //第0区
data1 :array [0..511] of char; //第1区
data2 :array [0..511] of char; //第2区
data3 :array [0..511] of char; //第3区
data4 :array [0..511] of char; //第4区
end;
PSoftDogData =^TSoftDogData;
C#
[DllImport("CommonDLL.dll", EntryPoint = "GetSoftDogData", CharSet = CharSet.Auto,CallingConvention=CallingConvention.StdCall)] ///自动送封字段CharSet.Auto 调用入口点的名称DLLEntryPoint
public static extern byte GetSoftDogData(int myuid, ref byte[] TestCode);
private void Button_Click_2(object sender, RoutedEventArgs e)
{
int myuid = 24825159;
SoftDogData softdogData = new SoftDogData();
byte[] data = new byte[1024];
MessageBox.Show(GetSoftDogData(myuid, ref data).ToString());
}
怎么传参数啊!!!! 展开
Delphi 函数结构
var dognum :byte ;
SoftDogData :PSoftDogData;
myuid :integer;
begin
///其中SoftDogData是个指针,指向一个下面的结构体 new(SoftDogData);
myuid :=24825159;
if GetSoftDogData(myuid,PChar(SoftDogData))>0 then
begin
EditData0.Text :=StrPas(SoftDogData.data0);
EditData1.Text :=StrPas(SoftDogData.data1);
EditData2.Text :=StrPas(SoftDogData.data2);
EditData3.Text :=StrPas(SoftDogData.data3);
EditData4.Text :=StrPas(SoftDogData.data4);
exit;
end;
TSoftDogData =record
data0 :array [0..511] of char; //第0区
data1 :array [0..511] of char; //第1区
data2 :array [0..511] of char; //第2区
data3 :array [0..511] of char; //第3区
data4 :array [0..511] of char; //第4区
end;
PSoftDogData =^TSoftDogData;
C#
[DllImport("CommonDLL.dll", EntryPoint = "GetSoftDogData", CharSet = CharSet.Auto,CallingConvention=CallingConvention.StdCall)] ///自动送封字段CharSet.Auto 调用入口点的名称DLLEntryPoint
public static extern byte GetSoftDogData(int myuid, ref byte[] TestCode);
private void Button_Click_2(object sender, RoutedEventArgs e)
{
int myuid = 24825159;
SoftDogData softdogData = new SoftDogData();
byte[] data = new byte[1024];
MessageBox.Show(GetSoftDogData(myuid, ref data).ToString());
}
怎么传参数啊!!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询