Reputation:
I have 4 processes in which are related to each other. In the first program, I have a function in which it gets input from the user and then execute the second program. The following function execute the second program:
void MainWindow::ExecuteCuiMode(QString arg_username, QString arg_password, QString arg_domain, QString arg_computer_name, QString arg_ui_type)
{
QString FinalUsername = "user:";
QString FinalPassword = "ntlm:";
QString FinalDomain = "domain:";
QString FinalComputerName = "pc:";
QString FinalUIType = "ui:";
FinalUsername.append(arg_username);
FinalPassword.append(arg_password);
FinalDomain.append(arg_domain);
FinalComputerName.append(arg_computer_name);
FinalUIType.append(arg_ui_type);
QString Arguments = FinalUsername + " " + FinalPassword + " " + FinalDomain + " " + FinalComputerName + " " + FinalUIType;
if(ShellExecuteA(NULL, NULL, "Backend.exe", Arguments.toStdString().c_str(), NULL, SW_SHOWNORMAL))
{
statusBar()->showMessage("Program Status: Connected to " + FinalComputerName);
}
else
{
statusBar()->showMessage("Program Status: Connection Failed.");
}
}
In the second program (Backend.exe), I try to access to parameters which passed to the program like the following example:
QString firstArgument = QApplication::arguments().at(1);
QMessageBox::information(this, "Message", firstArgument);
but when the second program executed, it shows me nothing. I don't know where is the problem.
Upvotes: 0
Views: 132
Reputation: 776
there is such a subtle point that the arguments that QApplication does not handle are simply deleted and those that don't work with them are equal to 1 so it’s not a fact that 1 will be the arguments that you want, I think that you need to call
QStringList QCoreApplication :: arguments ()
and looked if there are any is that argument on the list?
Upvotes: 0