代码如下: void __stdcall ViewATSE(uint8_t Para, int32_t *a, int32_t *b)
代码如上所示,Para是输入参数,a 和b 是输出参数,在C# 中该怎么进行声明调用呢,第一次用C#,请教大家了
代码如上所示,Para是输入参数,a 和b 是输出参数,在C# 中该怎么进行声明调用呢,第一次用C#,请教大家了
解决方案 »
- C#里面 怎么样 在1个Datatable里面添加2张表的数据?
- 怎么把FCKeditor的值清空
- 删除重复记录出错
- 怎样对数据进行加减乘除
- FileUpload上传大小问题
- 极度郁闷中,,关于程序运行效率问题,,高手in
- iBatis.net中使用System.Transaction时报错不能连接数据库
- Sunmast(速马, Reloading...) 请进。这个破论坛,管理界面看到已经结帖并给分,直接看却没有给分。
- 关于DataGrid中加入ComboBox,有小小的不完美怎么也改正不了
- SQL语句转换c# lambda 表达式问题
- 题目求解答
- 某1控件包含多个数据模型中的属性,应该怎么办?
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport(@"D:\C#DLL\APPDLL\WindowsApplication1\ViewATSE.dll", EntryPoint = "ViewATSE")]
public static extern void ViewATSE(Byte Para, ref Int32 mode, ref Int32 fun,ref Int32 point,ref UInt32 LED,ref UInt32 LED1); private void button1_Click(object sender, EventArgs e)
{
Byte Para;
Int32 mode,fun,point;
UInt32 LED,LED1;
Para =0;
ViewATSE(Para,mode,fun,point,LED,LED1);
MessageBox.Show(Convert.ToString(mode));
}
}
}
我现在在C#中的声明如上,但是一运行提示
错误 1 与“WindowsApplication1.Form1.ViewATSE(byte, ref int, ref int, ref int, ref uint, ref uint)”最匹配的重载方法具有一些无效参数错误 2 参数“2”必须与关键字“ref”一起传递 D:\C#DLL\APPDLL\WindowsApplication1\Form1.cs
错误 3 参数“3”必须与关键字“ref”一起传递 D:\C#DLL\APPDLL\WindowsApplication1\Form1.cs
错误 4 参数“4”必须与关键字“ref”一起传递 D:\C#DLL\APPDLL\WindowsApplication1\Form1.cs
错误 5 参数“5”必须与关键字“ref”一起传递 D:\C#DLL\APPDLL\WindowsApplication1\Form1.cs
错误 6 参数“6”必须与关键字“ref”一起传递 D:\C#DLL\APPDLL\WindowsApplication1\Form1.cs
有什么错误吗
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport(@"D:\C#DLL\APPDLL\WindowsApplication1\ViewATSE.dll", EntryPoint = "ViewATSE",CallingConvention=CallingConvention.StdCall)]
public static extern void ViewATSE( byte Para, ref int mode,ref int fun,ref int point,ref UInt32 LED,ref UInt32 LED1); private void button1_Click(object sender, EventArgs e)
{
Byte Para;
Int32 mode,fun,point;
UInt32 LED,LED1;
Para =0;
mode=0;
fun=0;
point=0;
LED =0;
LED1 =0;
ViewATSE( Para, ref mode, ref fun, ref point, ref LED,ref LED1);
MessageBox.Show(Convert.ToString(mode));
MessageBox.Show(Convert.ToString(fun ));
MessageBox.Show(Convert.ToString(fun ));
}
}
}
我上面这样编译了以后不报错了,out 和ref的区别就是参数的初始化吧,别的应该没什么吧,调用DLL的时候,系统会卡死,但是用DELPHI调用的时候,就没问题,下面是我DELPHI的声明 procedure ViewATSE(Para:Byte;Mode:PInteger;Fun:PInteger;arrow:PInteger,LED:Pinteger;Led1:Pinteger);stdcall ;external 'ViewATSE.dll'
为什么用DELPHI调用没问题,用C#就卡死呢
调用出错delphi程序中调用就没问题