Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1503602
  • 博文数量: 329
  • 博客积分: 2773
  • 博客等级: 少校
  • 技术积分: 4219
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-24 14:17
个人简介

淡定从容,宁静致远

文章分类

全部博文(329)

文章存档

2016年(4)

2015年(50)

2014年(68)

2013年(45)

2012年(162)

分类: C#/.net

2014-11-10 14:08:12

extern "C" __declspec(dllexport) int scanRe(char* data)
{
    strcpy(data,"47");
    return 0;
}

在c#中接收返回值用 ref byte
        [DllImport("PDAScandll.dll",CharSet=System.Runtime.InteropServices.CharSet.Auto)]
        public static extern int scanRe( ref byte param2);
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] param2 = new byte[255];//新建字节数组
           
            scanRe(ref param2[0]);//向dll函数传入参数

            string s = System.Text.Encoding.GetEncoding("GB2312").GetString(param2, 0, param2.Length);
            //将字节数组转换为字符串

            label1.Text =s;
          }


阅读(2474) | 评论(0) | 转发(0) |
0

上一篇:C#调用c dll

下一篇:C#获取路径

给主人留下些什么吧!~~