admin管理员组

文章数量:1125346

I'm doing a imple MFC on VS2022.

What it does is choosing a file ,a comport and then system call my executable(input myfile).

like this

private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
String^ Comport;
String^ FWPath;
String^ Cmd;

Comport = cbPort->Text;
FWPath = openFileDlg->FileName;
Cmd = ".\mytest.exe " + path + " " + geoComport->Substring(3);
msclr::interop::marshal_context ctx;
const char* converted = ctx.marshal_as <const char*>(Cmd);
MessageBox::Show(Cmd->ToString());
std::system(converted);}

I get my file path and comport already.

And I can see that the thole Cmd on messagebox, and certain that it is right.

But the last line system(converted) does work imagined.

A window pop up and desappear very quickly.

Is that what i wrong doing with the function system()?

本文标签: windowsMFC system call not work using C command system()Stack Overflow