C调用C++的DLL搜集整理的所有数据类型转换方式.doc
文本预览下载声明
? ?//C++中的DLL函数原型为??????? //extern C __declspec(dllexport) bool 方法名一(const char* 变量名1, unsigned char* 变量名2)??????? //extern C __declspec(dllexport) bool 方法名二(const unsigned char* 变量名1, char* 变量名2)
??????? //C#调用C++的DLL搜集整理的所有数据类型转换方式,可能会有重复或者多种方案,自己多测试??????? //c++:HANDLE(void?? *)????????? ----??? c#:System.IntPtr ??????? //c++:Byte(unsigned?? char)???? ----??? c#:System.Byte ??????? //c++:SHORT(short)????????????? ----??? c#:System.Int16 ??????? //c++:WORD(unsigned?? short)??? ----??? c#:System.UInt16 ??????? //c++:INT(int)????????????????? ----??? c#:System.Int16??????? //c++:INT(int)????????????????? ----??? c#:System.Int32 ??????? //c++:UINT(unsigned?? int)????? ----??? c#:System.UInt16??????? //c++:UINT(unsigned?? int)????? ----??? c#:System.UInt32??????? //c++:LONG(long)??????????????? ----??? c#:System.Int32 ??????? //c++:ULONG(unsigned?? long)??? ----??? c#:System.UInt32 ??????? //c++:DWORD(unsigned?? long)??? ----??? c#:System.UInt32 ??????? //c++:DECIMAL?????????????????? ----??? c#:System.Decimal ??????? //c++:BOOL(long)??????????????? ----??? c#:System.Boolean ??????? //c++:CHAR(char)??????????????? ----??? c#:System.Char ??????? //c++:LPSTR(char?? *)?????????? ----??? c#:System.String ??????? //c++:LPWSTR(wchar_t?? *)?????? ----??? c#:System.String ??????? //c++:LPCSTR(const?? char?? *)? ----??? c#:System.String ??????? //c++:LPCWSTR(const?? wchar_t?? *)????? ----??? c#:System.String ??????? //c++:PCAHR(char?? *)?? ----??? c#:System.String ??????? //c++:BSTR????????????? ----??? c#:System.String ??????? //c++:FLOAT(float)????? ----??? c#:System.Single ??????? //c++:DOUBLE(double)??? ----??? c#:System.Double ??????? //c++:VARIANT?????????? ----??? c#:System.Object ??????? //c++:PBYTE(byte?? *)?? ----??? c#:System.Byte[]
??????? //c++:BSTR????? ----??? c#:StringBuilder??????? //c++:LPCTSTR?? ----??? c#:StringBuilder??????? //c++:LPCTSTR?? ----??? c#:string??????? //c++:LPTSTR??? ----??? c#:[MarshalAs(UnmanagedType.LPTStr)] s
显示全部