非静态成员引用必须相对于特定对象
A non-static member reference must be relative to a specific object
我试图让文本框 tb_key
中的文本写入我的 std::string Key
Variable ,方法是:
std::string Key = TRIPRECOILWARE::LoginForm::tb_key->Text;
我收到一条错误消息:
A non-static member reference must be relative to a specific
object
我尝试搜索,但找不到真正适合我的东西。
最小可重现示例:
LoginForm.h
namespace TRIPRECOILWARE {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
private: System::Void tb_key_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
}
}
LoginForm.cpp
std::string Key = TRIPRECOILWARE::LoginForm::tb_key->Text;
我正在尝试在 LoginForm.h
中使用它
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if (Authenticate(StringToChar(Key), (StringToChar(hwid)))) // Authenticates key & hwid
{
this->Hide();
Software^ soft = gcnew Software();
soft->Show();
}
Basically, I want to get Key from Textbox called tb_key
and write
it to my Key
variable defined above. Then use that key to
authenticate and perform code
你真正的问题是 How to turn System::String^ into std::string?
的重复
更正后的代码:
#include <msclr\marshal.h>
#include <msclr\marshal_cppstd.h>
using namespace System;
using namespace msclr::interop;
void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
std::string Key = marshal_as<std::string>(tb_key->Text);
if (Authenticate(Key.c_str(), hwid.c_str())) // Authenticates key & hwid
{
Hide();
Software^ soft = gcnew Software();
soft->Show();
}
}
我试图让文本框 tb_key
中的文本写入我的 std::string Key
Variable ,方法是:
std::string Key = TRIPRECOILWARE::LoginForm::tb_key->Text;
我收到一条错误消息:
A non-static member reference must be relative to a specific object
我尝试搜索,但找不到真正适合我的东西。
最小可重现示例:
LoginForm.h
namespace TRIPRECOILWARE {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
private: System::Void tb_key_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
}
}
LoginForm.cpp
std::string Key = TRIPRECOILWARE::LoginForm::tb_key->Text;
我正在尝试在 LoginForm.h
中使用它private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if (Authenticate(StringToChar(Key), (StringToChar(hwid)))) // Authenticates key & hwid
{
this->Hide();
Software^ soft = gcnew Software();
soft->Show();
}
Basically, I want to get Key from Textbox called
tb_key
and write it to myKey
variable defined above. Then use that key to authenticate and performcode
你真正的问题是 How to turn System::String^ into std::string?
的重复更正后的代码:
#include <msclr\marshal.h>
#include <msclr\marshal_cppstd.h>
using namespace System;
using namespace msclr::interop;
void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
std::string Key = marshal_as<std::string>(tb_key->Text);
if (Authenticate(Key.c_str(), hwid.c_str())) // Authenticates key & hwid
{
Hide();
Software^ soft = gcnew Software();
soft->Show();
}
}