问题描述
我正在制作一个鼠标,我是用我的 arduino 制作的,我正在通过串行端口将数据(x,y,以及按钮是否被按下(我的数据看起来像这样:x234y256s0)发送到c++/cli 控制台应用程序(CLR)。我成功地将数据传递给 cli,然后我将数据转换为 std::string,然后将该字符串分成 3 个字符串 x、y 和 s,然后我想将那些 { {1}} 转换为整数,我首先需要将它们转换为系统字符串(String^),这也成功了,然后我尝试将其转换为这样的整数:std::strings
(稍后将显示我的整个代码),那行给了我这个错误:
int X = System::Convert::ToInt32(x1);
此外,我在代码 System.FormatException: 'Input string was not in a correct format.'
的末尾添加了这一行,该行给了我 2 个错误:
SetCursorPos(mouseX,mouseY);
我真的不知道这两个错误是什么意思,我以前从未使用过 CLI,而且我很少使用 C++。
Severity Code Description Project File Line Suppression State
Error LNK2028 unresolved token (0A0001DE) "extern "C" int __stdcall SetCursorPos(int,int)" (?SetCursorPos@@$$J18YGHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z) arduinoSerial2 C:\..... 1 and
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "extern "C" int __stdcall SetCursorPos(int,int)" (?SetCursorPos@@$$J18YGHHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z) arduinoSerial2 C:\..... 1,
解决方法
试试:int i = int::Parse(str); // string to int