c#调用c语言dll,形参有char*,无法获得char*内容。但是在c++中调用dll无问题。说明dll正确,C#中代码有问题。
直接解决方法:未解决,dll没问题,就是调用后存储在webtoken中读取有问题,求大神告知解决方法:
变相解决方法:修改dll文件,将形参char*作为返回值char*返回。
原先的c函数声明:
#ifndef _DLLMAIN_H
#define _DLLMAIN_H
#ifndef DLL_EXPORT
#define _LIBAPI __declspec(dllexport)
#else
#define _LIBAPI __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
_LIBAPI void getWebToken(const char* appkey, const char* counter, char* webtoken)
#ifdef __cplusplus
}
#endif
#endif /* _DLL_H_ */
原先的调用方式:无法获得webtoken中的字符串。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;