C# 怎么调用C++ 定义的const std::vector<MusicCommand> 这样类型的方法 10
其中MusicCommand是个结构体如下:structAirConditionStatus{uint8_tid;boolis_on;uint8_tmode;boolis...
其中MusicCommand是个结构体如下:
struct AirConditionStatus
{
uint8_t id;
bool is_on;
uint8_t mode;
bool is_auto;
uint8_t wind_speed;
uint8_t set_temp;
int8_t current_temp;
};
DLL_API bool ControlAirCondition(const std::string &uid,
const std::vector<AirConditionStatus> &air_conditions_status);
PS:试过用List<AirConditionStatus>
C#代码:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AirConditionStatus
{
public byte id;
public bool is_on;
public byte mode;
public bool is_auto;
public byte wind_speed;
public byte set_temp;
public byte current_temp;
}
[DllImport(@"AppDll.dll", EntryPoint = "ControlAirCondition", CharSet = CharSet.Auto)]
public static extern bool ControlAirCondition(char[] uid, List<AirConditionStatus> air_conditions_status);
标题MusicCommand枚举换成AirConditionStatus, 打错了 展开
struct AirConditionStatus
{
uint8_t id;
bool is_on;
uint8_t mode;
bool is_auto;
uint8_t wind_speed;
uint8_t set_temp;
int8_t current_temp;
};
DLL_API bool ControlAirCondition(const std::string &uid,
const std::vector<AirConditionStatus> &air_conditions_status);
PS:试过用List<AirConditionStatus>
C#代码:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AirConditionStatus
{
public byte id;
public bool is_on;
public byte mode;
public bool is_auto;
public byte wind_speed;
public byte set_temp;
public byte current_temp;
}
[DllImport(@"AppDll.dll", EntryPoint = "ControlAirCondition", CharSet = CharSet.Auto)]
public static extern bool ControlAirCondition(char[] uid, List<AirConditionStatus> air_conditions_status);
标题MusicCommand枚举换成AirConditionStatus, 打错了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询