Ссылка на неразрешенную лексему и на неразрешенный внешний символ. c++/clr
Я никак не могу вызвать функцию LoginT() которая находится в файле MyForm.cpp из файла заголовка MyForm.h Также пытался использовать __declspec(dllexport) но была ошибка с3395 __declspec(dllexport) невозможно применять к функции с соглашение вызова __clrcall MyForm.cpp
#include "MyForm.h"
#include <Windows.h>
#include <mysql.h>
#include <msclr\marshal_cppstd.h>
#include <TlHelp32.h>
using namespace Interface1;// Название проекта
using namespace std;
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew MyForm);
return 0;
}
int qstate;
wstring hwidWString;
HW_PROFILE_INFO hwProfileInfo;
bool isLoginned;
void LoginT(System::String^ login, System::String^ password)
{
GetCurrentHwProfile(&hwProfileInfo);
hwidWString = hwProfileInfo.szHwProfileGuid;
string hwid(hwidWString.begin(), hwidWString.end());
char chars[] = "{}";
for (unsigned int i = 0; i < strlen(chars); ++i)
{
// you need include <algorithm> to use general algorithms like std::remove()
hwid.erase(std::remove(hwid.begin(), hwid.end(), chars[i]), hwid.end());
}
//Конвертация System::String в std::string
msclr::interop::marshal_context context;
std::string LoginString = context.marshal_as<std::string>(login);
std::string PasswordString = context.marshal_as<std::string>(login);
//Подключение к mysql
MYSQL* conn;
MYSQL_ROW row;
MYSQL_RES* res;
conn = mysql_init(0);
conn = mysql_real_connect(conn, "localhost", "root", "root", "testdb1", 3307, NULL, 0);
if (conn) {
string query = "SELECT * FROM table1 WHERE `login` = \"" + LoginString + "\" AND `password` = \"" + PasswordString + "\ AND `hwid` = \"" + hwid + "\"";
const char* q = query.c_str();
qstate = mysql_query(conn, q);
if (!qstate)
{
res = mysql_store_result(conn);
while (row = mysql_fetch_row(res))
{
isLoginned = true;
}
}
else
{
string query = "SELECT * FROM table1 WHERE `login` =\"" + LoginString + "\" AND `password` = \"" + PasswordString + "\ AND `hwid` = NULL";
const char* q = query.c_str();
qstate = mysql_query(conn, q);
if (!qstate)
{
string query = "UPDATE table1 WHERE `login` = \"" + LoginString + "\" AND `password` = \"" + PasswordString + "\" SET `hwid` = \"" + hwid + "\"";
const char* q = query.c_str();
qstate = mysql_query(conn, q);
}
else {
bool a = false;
Interface1::MyForm::check(false);
}
}
}
}
MyForm.h
#pragma once
#include <string>
#include <string.h>
#include <Windows.h>
std::string a;
namespace Interface1 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
void LoginT(System::String^ login, System::String^ password);
/// <summary>
/// Сводка для MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: добавьте код конструктора
//
}
protected:
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ TextHello;
private: System::Windows::Forms::TextBox^ Login;
private: System::Windows::Forms::TextBox^ Password;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
protected:
private:
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->TextHello = (gcnew System::Windows::Forms::Label());
this->Login = (gcnew System::Windows::Forms::TextBox());
this->Password = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft YaHei UI", 25, System::Drawing::FontStyle::Bold));
this->button1->Location = System::Drawing::Point(108, 314);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(165, 67);
this->button1->TabIndex = 0;
this->button1->Text = L"Login";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// TextHello
//
this->TextHello->AutoSize = true;
this->TextHello->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25));
this->TextHello->Location = System::Drawing::Point(101, 9);
this->TextHello->Name = L"TextHello";
this->TextHello->Size = System::Drawing::Size(186, 39);
this->TextHello->TabIndex = 1;
this->TextHello->Text = L"Hello User!";
//
// Login
//
this->Login->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15));
this->Login->Location = System::Drawing::Point(163, 85);
this->Login->Name = L"Login";
this->Login->Size = System::Drawing::Size(170, 30);
this->Login->TabIndex = 2;
//
// Password
//
this->Password->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15));
this->Password->Location = System::Drawing::Point(163, 180);
this->Password->Name = L"Password";
this->Password->Size = System::Drawing::Size(170, 30);
this->Password->TabIndex = 3;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25));
this->label1->Location = System::Drawing::Point(12, 77);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(101, 39);
this->label1->TabIndex = 4;
this->label1->Text = L"Login";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 23));
this->label2->Location = System::Drawing::Point(6, 174);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(151, 35);
this->label2->TabIndex = 5;
this->label2->Text = L"Password";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(393, 393);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->Password);
this->Controls->Add(this->Login);
this->Controls->Add(this->TextHello);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
System::String^ l = Login->Text;
System::String^ p = Login->Text;
LoginT(l, p);
}
public: static void check(bool isLogin) {
MyForm inter;
inter.h();
}
public: void h() {
TextHello->Text = "Error login";
Sleep(5000);
TextHello->Text = "Hello User!";
}
};
}