Calling a C++ dll with unsigned char* parameters
unsigned char* 等价 BYTE*
例1:
C++:
int __stdcall LIVESCAN_GetFPRawData(int nChannel, unsigned char *pRawData);
C#
[DllImport("GALS1701.dll", EntryPoint = "LIVESCAN_GetFPRawData", CallingConvention = CallingConvention.Cdecl)]
unsafe public static extern int GetFPRawData(int nChannel, byte* pRawData);
unsafe
{
Byte[] bytes = new Byte[ * + ];
//就是固定“fixed 语句禁止垃圾回收器重定位可移动的变量”
fixed (byte* array = bytes)
{
Livescan.GetFPRawData(, array);
}
}
例2:
C++
extern "C" _declspec(dllexport) int Auto_Capture(BYTE *pBmpData)
C#
[DllImport("LivescanDll.dll", EntryPoint = "Auto_Capture", CallingConvention = CallingConvention.Cdecl)]
public static extern int Auto_Capture(Byte[] pBmpData);
Byte[] bytes = new Byte[ * + ];
int result = Livescan.Auto_Capture(bytes);
Calling a C++ dll with unsigned char* parameters的更多相关文章
- C#封装C++DLL(特别是char*对应的string)
1.新建一个C#-Windows-类库(用于创建C#类库(.dll)的项目)类型的工程 2.对于普通C++函数 XXXX_API void cppFun(int i); 在cs代码中添加 [DllIm ...
- c++unsigned char的输出问题
unsigned char的范围是0~255,在用cout输出的时候要显示数字的话记得进行int的强制转化才可以,否则都是输出的字符,除此之外的所有比较转换成整数在做比较吧 除此之外,在最近的项目里由 ...
- unsigned char 类型
在蓝牙4.0的开发中,很多数据类型都用到了 unsigned char ,我觉得用这个类型的一个原因是相比较于整型,它占的空间更少. 比如: unsigned char a = 1; // 占1个字 ...
- char、unsigned char、BYTE
首先uchar就是BYTE:Typedef unsigned char BYTE: char:就是signed char,是一个字节,8个位.第8位是符号位,所以可以表示-128~127共256个符号 ...
- unsigned char 无符号整形 减法运算
对于一个字节来说: unsigned char : 0 ~ 255 0000 0000 ~ 1111 1111 char :-128 ~ 127 ...
- char, signed char, and unsigned char in C++
关于这三者的区别stackoverrflow里有一个答案是这样说的: 3.9.1 Fundamental types [basic.fundamental] 1 Objects declared as ...
- unsigned char 转字符串:
通常送显示的都是字符串,对于int long float转字符串有对应的函数,还有sprintf进行格式输出,对于嵌入式和单片机大多都用unsigned char型变量,转字符串需要自己编写函数,需要 ...
- signed char、unsigned char
什么是无符号char类型?与常见的char类型有何不同? 在c++中有三种不同的字符类型:char,signed char,unsigned char.如果要应用与文本字符,就使用不加限制的char类 ...
- char 与 unsigned char的本质区别
在C中,默认的基础数据类型均为signed,现在我们以char为例,说明(signed) char与unsigned char之间的区别 首先在内存中,char与unsigned char没有什么不同 ...
随机推荐
- Python学习笔记:03语法
Python 语法 Python语法包括: 模块函数导入 赋值 判断循环语句 模块导入 import somemodule somemodule.somefunc from somemodule im ...
- python执行shell获取硬件参数写入mysql
最近要获取服务器各种参数,包括cpu.内存.磁盘.型号等信息.试用了Hyperic HQ.Nagios和Snmp,它们功能都挺强大的,但是于需求不是太符,亦或者太heavy. 于是乎想到用python ...
- 一分钟让你明白CSS中的盒模型
想必初学者对CSS盒模型总是很困惑吧.下面一分钟让你彻底明白盒模型: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" &q ...
- PYTHON WEATHER
小玩一下python强大的库文件,调api获取天气情况 #coding:utf-8 import urllib import json content = urllib.urlopen('http:/ ...
- Solr4.8.0源码分析(8)之Lucene的索引文件(1)
Solr4.8.0源码分析(8)之Lucene的索引文件(1) 题记:最近有幸看到觉先大神的Lucene的博客,感觉自己之前学习的以及工作的太为肤浅,所以决定先跟随觉先大神的博客学习下Lucene的原 ...
- js中undefined,null,NaN的区别
1.类型分析: js中的数据类型有undefined,boolean,number,string,object等5种,前4种为原始类型,第5种为引用类型.var a1;var a2 = true;va ...
- 【HDOJ】1109 Run Away
基础模拟退火. /* poj 1379 */ #include <iostream> #include <cstdio> #include <cstdlib> #i ...
- BZOJ1708: [Usaco2007 Oct]Money奶牛的硬币
1708: [Usaco2007 Oct]Money奶牛的硬币 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 513 Solved: 329[Submi ...
- -_-#URL区分大小写吗
Should url be case sensitive?
- uboot mkimage使用详解
mkimage使用详解uboot源代码的tools/目录下有mkimage工具,这个工具可以用来制作不压缩或者压缩的多种可启动映象文件. mkimage在制作映象文件的时候,是在原来的可执行映象文件的 ...