传参方式:
1. ::ShellExecuteA(NULL, "open", strPath.c_str(), strCmd.c_str(), NULL, SW_SHOW);
2. QProcess::startDetached(strPath, QStringList(strCmd));
接收方式:
//方式一:
for (int i=0; i<argc;i++)
{
cout << argv[i] << endl; //1.会丢失引号 2.不会丢失引号
}
//方式二:
QStringList listCmd = qApp->arguments(); //1.会丢失引号 2.不会丢失引号
//方式三:
std::string jsonCmd = ::GetCommandLineA(); //1.不会丢失引号 2.引号变成"
//方式四:
//传参:ShellExecuteA
QString json = "{"id":1,"name":"tingtaishou"}";
QByteArray text(json.toLatin1());
text = text.toBase64();
QString strCmd(text); //转码传入
QStringList listCmd = qApp->arguments();
for (int i = 1; i < listCmd.count(); i++)
{
QByteArray byte = QByteArray::fromBase64(listCmd[i].toLatin1()); //解码接收
QString data(byte); //不会丢失引号
}
相关:https://blog.csdn.net/hp_cpp/article/details/107489723