在html中执行.exe (c++)或转换为javascript
Executing .exe (c++) in html or converting to javascript
是否可以在服务器/网页上运行EXE (c++)并使EXE返回响应,或者我必须将此EXE (c++)转换为javascript?
如果我必须将代码转换为javascript,我该怎么做?我知道javascript的基础知识,但我不知道如何读写。txt文件。
基本上我的代码是一个登录系统,我想使用我的网站,所以我不必使用mysql或数据库。我知道这是一个缓慢的,可能是一个愚蠢的方法,但这是一个项目。任何帮助都是感激的!
编辑:你按下登录按钮,然后如果你提示与EXE文件,你可以看到上面。然后EXE文件发送回服务器,如果登录成功和信息。EXE文件必须在服务器上,所以客户端不必下载它。
代码:#include <iostream>
#include <string>
#include <fstream>
#include <time.h>
using namespace std;
void cls() { system("cls"); }
bool mainPage(string &username, string &password) {
cls();
cout << "Username: "; getline(cin, username);
cout << "Password: "; getline(cin, password);
if(username != "" && password != "") {
return true;
}
else {
return false;
}
}
bool checkLogin(string &username, string &password, string &email, string &firstName, string &lastName) {
string pw = "";
ifstream ifile(username + ".txt");
if(ifile.is_open()) {
ifile >> pw >> email >> firstName >> lastName;
if(pw == password) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
bool loginFail() {
string fail = "";
string undef = "";
cls();
cout << "'reg'" << endl;
cout << "'main'" << endl;
getline(cin, fail);
if(fail == "reg") {
return true;
}
else if(fail == "main") {
return false;
}
else {
cout << "nCould not understand you." << endl;
getline(cin, undef);
return loginFail();
}
}
bool regist() {
string un;
string pw;
string em;
string fn;
string ln;
string undef = "";
cls();
cout << "'main'" << endl;
cout << "nNew username: "; getline(cin, un);
cout << "New password: "; getline(cin, pw);
if((un != "" && pw != "") && (un != "main" && pw != "main")) {
ifstream ifile(un + ".txt");
if (ifile.is_open()) {
cout << "nThis username is already taken." << endl;
getline(cin, undef);
return regist();
}
else {
cout << "nEmail: "; getline(cin, em);
cout << "nFirst name: "; getline(cin, fn);
cout << "Last name: "; getline(cin, ln);
if(em != "" && fn != "" && ln != "") {
ofstream ofile;
ofile.open(un + ".txt");
if (ofile.is_open()) {
ofile << pw << endl;
ofile << em << endl;
ofile << fn << endl;
ofile << ln << endl;
ofile.close();
cout << "nFile was successfully written to." << endl;
getline(cin, undef);
return true;
}
else {
cout << "nFile could not open." << endl;
getline(cin, undef);
return regist();
}
}
else {
cout << "nYou didn't enter one of the above." << endl;
getline(cin, undef);
return regist();
}
}
}
else if(un == "main" || pw == "main") {
return false;
}
else {
cout << "nYou didn't do it correct." << endl;
getline(cin, undef);
return regist();
}
}
void loginSuccess(string username, string password, string email, string firstName, string lastName) {
string undef = "";
cls();
cout << "You have successfully logged in." << endl;
cout << "nUsername: " << username << endl;
cout << "Password: " << password << endl;
cout << "nEmail: " << email << endl;
cout << "nFrist name: " << firstName << endl;
cout << "Last name: " << lastName << endl;
getline(cin, undef);
}
int main(void) {
system("color a");
string username = "";
string password = "";
string email = "";
string firstName = "";
string lastName = "";
if(!mainPage(username, password)) {
return main();
}
else {
if(!checkLogin(username, password, email, firstName, lastName)) {
if(!loginFail()) {
return main();
}
else {
if (!regist()) {
return main();
}
else {
return main();
}
}
}
else {
loginSuccess(username, password, email, firstName, lastName);
}
}
}
你不能在浏览器中使用Javascript编写文件系统。我认为您应该使用客户机-服务器体系结构来编写应用程序。例如,客户机将是一个简单的HTML页面,其中包含用户名和密码的输入,服务器将保存并检查用户的凭据。在这种情况下,您可以使用Javascript将数据从页面发送到服务器。
相关文章:
- 防止主数据类型C++的隐式转换
- 模板参数替换失败,并且未完成隐式转换
- 努力将整数转换为链表。不知道我在这里做错了什么
- HEX值到wchar_t字符(UTF-8)的转换
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 将 Qvector<uint8_t> 转换为 QString
- 嘿,我正在尝试将此c ++转换为javascript,但有些东西不起作用
- 将Wiimote MAC地址转换为PIN码,从C++转换为Python或Javascript
- 如何将Javascript正则表达式转换为C++11正则表达式
- 如何使用 emscripten 将使用 zlib 的项目转换为 javascript?
- 将协议缓冲区中的二进制双精度数组转换为 JavaScript 数字
- QML/QT 无法将 C++ 中的 QList<QVariantMap> 转换为 JavaScript 中的对象数组
- 用指针 *将C 转换为JavaScript(节点)
- JavaScript 和 C++ 布尔转换
- 将 JavaScript Array.slice + 隐式扩展转换为 C++ vector
- 将Javascript正则表达式模式转换为C++std::regex的规则
- 在html中执行.exe (c++)或转换为javascript
- Qt Qvariantlist转换为javascript数组失败
- JavaScript到C++的转换:%运算符出错
- 将JavaScript转换为C++