在文本框(combobox)中显示std :: string

时间:2019-05-23 07:53:04

标签: c++ visual-studio-2017 c++-cli

我从注册表中读取COM端口,并以cstring形式获取结果。 现在,我想在文本框(组合框)中显示结果。

错误消息是:

  

System :: Windows :: Forms :: TextBox :: Text :: set”无法与已提交的参数列表一起调用。

参数类型为:std::string

对象类型为:System::Windows::Forms::TextBox^

我用std::string(strData, strData.GetLength());尝试过,但是没有用。

private: void getComports() {
            HKEY hKey;
            LONG res;
            DWORD dwIndex = 0, dwName, dwData;
            char chName[MAX_PATH];
            CString strData;
            DWORD dwSize = 1024;

            res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), 0, KEY_READ, &hKey);

            if (!res) {
                do {
                    dwName = MAX_PATH;
                    dwData = MAX_PATH;
                    res = RegEnumValue(hKey, dwIndex++, chName, &dwName, NULL, NULL, (BYTE *)strData.GetBufferSetLength((int)dwSize), &dwData);
                    if (res != ERROR_NO_MORE_ITEMS)
                    {
                        textBox_middle_left_inside_1->Text = std::string(strData, strData.GetLength());
                    }
                } while (res != ERROR_NO_MORE_ITEMS);

                RegCloseKey(hKey);
            }
}

如何在文本框(组合框)中显示结果?

感谢支持!

0 个答案:

没有答案
相关问题