Type correspondence between C/C ++ and C,

Source: Internet
Author: User

Type correspondence between C/C ++ and C,

Recently, we have been studying functions related to pos printers. Calling winapi and cross-process communication all involve conversions between types.

C/C ++

C #

HANDLE, LPDWORD, LPVOID, void *

IntPtr

Maid, LPSTR, LPSTR, char *, const char *, Wchar_t *, LPWSTR

String [in], StringBuilder [in, out]

DWORD, unsigned long, Ulong

UInt32, [financialas (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. hIn

Unmanaged C language type

Managed class name

Description

HANDLE

Void *

System. IntPtr

32-bit Windows and 64-bit Windows.

BYTE

Unsigned char

System. Byte

8-digit

SHORT

Short

System. Int16

16-bit

WORD

Unsigned short

System. UInt16

16-bit

INT

Int

System. Int32

32-bit

UINT

Unsigned int

System. UInt32

32-bit

LONG

Long

System. Int32

32-bit

BOOL

Long

System. Int32

32-bit

DWORD

Unsigned long

System. UInt32

32-bit

ULONG

Unsigned long

System. UInt32

32-bit

CHAR

Char

System. Char

It is modified with ANSI.

LPSTR

Char *

System. String or System. Text. StringBuilder

It is modified with ANSI.

LPCSTR

Const char *

System. String or System. Text. StringBuilder

It is modified with ANSI.

LPWSTR

Wchar_t *

System. String or System. Text. StringBuilder

Use Unicode.

LPCWSTR

Const wchar_t *

System. String or System. Text. StringBuilder

Use Unicode.

FLOAT

Float

System. Single

32-bit

DOUBLE

Double

System. Double

64-bit

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.