C/C++与C#之间类型的对应
最近在研究pos打印机相关功能, 调用winapi以及跨进程通信等,都涉及到类型之间的转换。
C/C++ |
C# |
HANDLE, LPDWORD, LPVOID, void* |
IntPtr |
LPCTSTR, LPCTSTR, LPSTR, char*, const char*, Wchar_t*, LPWSTR |
String [in], StringBuilder [in, out] |
DWORD, unsigned long, Ulong |
UInt32, [MarshalAs(UnmanagedType.U4)] |
bool |
bool |
LP<struct> |
[In] ref <struct> |
SIZE_T |
uint |
LPDWORD |
out uint |
LPTSTR |
[Out] StringBuilder |
PULARGE_INTEGER |
out ulong |
WORD |
uInt16 |
Byte, unsigned char |
byte |
Short |
Int16 |
Long, int |
Int32 |
float |
single |
double |
double |
NULL pointer |
IntPtr.Zero |
Uint |
Uint32 |
Windows Data Type |
.NET Data Type |
BOOL, BOOLEAN |
Boolean or Int32 |
BSTR |
String |
BYTE |
Byte |
CHAR |
Char |
DOUBLE |
Double |
DWORD |
Int32 or UInt32 |
FLOAT |
Single |
HANDLE (and all other handle types, such as HFONT and HMENU) |
IntPtr, UintPtr or HandleRef |
HRESULT |
Int32 or UInt32 |
INT |
Int32 |
LANGID |
Int16 or UInt16 |
LCID |
Int32 or UInt32 |
LONG |
Int32 |
LPARAM |
IntPtr, UintPtr or Object |
LPCSTR |
String |
LPCTSTR |
String |
LPCWSTR |
String |
LPSTR |
String or StringBuilder* |
LPTSTR |
String or StringBuilder |
LPWSTR |
String or StringBuilder |
LPVOID |
IntPtr, UintPtr or Object |
LRESULT |
IntPtr |
SAFEARRAY |
.NET array type |
SHORT |
Int16 |
TCHAR |
Char |
UCHAR |
SByte |
UINT |
Int32 or UInt32 |
ULONG |
Int32 or UInt32 |
VARIANT |
Object |
VARIANT_BOOL |
Boolean |
WCHAR |
Char |
WORD |
Int16 or UInt16 |
WPARAM |
IntPtr, UintPtr or Object |
Wtypes.h 中的非托管类型 |
非托管 C 语言类型 |
托管类名 |
说明 |
HANDLE |
void* |
System.IntPtr |
在 32 位 Windows 操作系统上为 32 位,在 64 位 Windows 操作系统上为 64 位。 |
BYTE |
unsigned char |
System.Byte |
8 位 |
SHORT |
short |
System.Int16 |
16 位 |
WORD |
unsigned short |
System.UInt16 |
16 位 |
INT |
int |
System.Int32 |
32 位 |
UINT |
unsigned int |
System.UInt32 |
32 位 |
LONG |
long |
System.Int32 |
32 位 |
BOOL |
long |
System.Int32 |
32 位 |
DWORD |
unsigned long |
System.UInt32 |
32 位 |
ULONG |
unsigned long |
System.UInt32 |
32 位 |
CHAR |
char |
System.Char |
用 ANSI 修饰。 |
LPSTR |
char* |
System.String 或 System.Text.StringBuilder |
用 ANSI 修饰。 |
LPCSTR |
Const char* |
System.String 或 System.Text.StringBuilder |
用 ANSI 修饰。 |
LPWSTR |
wchar_t* |
System.String 或 System.Text.StringBuilder |
用 Unicode 修饰。 |
LPCWSTR |
Const wchar_t* |
System.String 或 System.Text.StringBuilder |
用 Unicode 修饰。 |
FLOAT |
Float |
System.Single |
32 位 |
DOUBLE |
Double |
System.Double |
64 位 |
C/C++与C#之间类型的对应的更多相关文章
- (转)C#与C++之间类型的对应
C#与C++之间类型的对应 Windows Data Type .NET Data Type BOOL, BOOLEAN Boolean or Int32 BSTR String BYTE Byte ...
- Go语言string,int,int64 ,float之间类型转换方法
(1)int转string ? 1 2 s := strconv.Itoa(i) 等价于s := strconv.FormatInt(int64(i), 10) (2)int64转string ? 1 ...
- C#与C++之间类型的对应
Windows Data Type .NET Data Type BOOL, BOOLEAN Boolean or Int32 BSTR String BYTE Byte CHAR Char DOUB ...
- C#与C++之间类型的对应{转}
Windows Data Type .NET Data Type BOOL, BOOLEAN Boolean or Int32 BSTR String BYTE Byte CHAR ...
- [转]Go语言string,int,int64 ,float之间类型转换方法
1 正文 (1)int转string s := strconv.Itoa(i) 等价于s := strconv.FormatInt(int64(i), 10) (2)int64转string i := ...
- C#与C++之间类型对应关系
//C++中的DLL函数原型为 //extern "C" __declspec(dllexport) bool 方法名一(const char* 变量名1, unsigned c ...
- 【opencv基础】opencv和dlib库中rectangle类型之间的转换
前言 最近使用dlib库的同时也会用到opencv,特别是由于对dlib库的画图函数不熟悉,都想着转换到opencv进行show.本文介绍一下两种开源库中rectangle类型之间的转换. 类型说明 ...
- Oracle中的数据类型和数据类型之间的转换
Oracle中的数据类型 /* ORACLE 中的数据类型: char 长度固定 范围:1-2000 VARCHAR2 长度可变 范围:1-4000 LONG 长度可变 最大的范围2gb 长字符类型 ...
- 浩哥解析MyBatis源码(十)——Type类型模块之类型处理器
原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/6715063.html 1.回顾 之前的两篇分别解析了类型别名注册器和类型处理器注册器,此二 ...
随机推荐
- html5 css练习 画廊 元素旋转
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- centos7安装nginx1.10.1
安装nginx. 1.首先在根目录下创建一个software文件夹用来存储下载的压缩包. 2.然后cd跳转的software文件夹下,进行压缩包的下载 wget -c https://nginx.or ...
- intellij idea 官方帮助文档翻译(一)安装
安装需求: 硬件需求: 最低2GB内存,推荐4GB内存 最少要有1.5GB的硬盘空间,以及1GB空间用于缓存 最低1024*768的分辨率 软件需求: intellij idea中包含了jre 1.8 ...
- WinForm窗体权限控制的简单实现
一.建立两张表 //存放要控制的窗体控件 CREATE TABLE [dbo].[AuthControl] ( [Id] INT IDENTITY (1, 1) NOT NULL, [NiceName ...
- Python 官方文档&教程
英文原版(3.6版): https://docs.python.org/3.6/index.html https://docs.python.org/3.6/tutorial/index.html 汉 ...
- python locust 性能测试:HttpSession
官网解释:用于在请求之间执行Web请求和保留(会话)cookie的类(以便能够登录和退出网站):记录每个请求,以便locust可以显示统计信息: from locust import TaskSet, ...
- Spring Boot 指定某个依赖的版本
Spring Boot 是个很好的框架,他为了他的一些功能生效,定义了一些依赖的版本. 比如说:Spring Boot 1.5.x 中elasticSearch是2.4.x的,这个是他本身就定义好的. ...
- CentOS7操作Redis4.0
单机安装 1. 从官网下载 redis-4.0.10.tar.gz 到本地,然后上传到VMware虚拟机上,存放地址随意. 2. 解压: tar -zxvf redis-4.0.10.tar.gz 3 ...
- 内存管理 re模块
# 内存垃圾回收机制: # 工作原理:引用计数 # 引用就+1 释放就是-1 当计数为0时 就会被垃圾回收机制回收 # 标记清除:解决循环引用导致的内存泄漏 # 标记:GC roots可以直接或间接访 ...
- 隐藏软键盘(解决自定义Dialog中无法隐藏的问题)
/** * Dialog中隐藏软键盘不管用 * @param activity */ public static void HideSoftKeyBoard(Activity activity){ t ...