I need to execute a DOS executable program with click of a button in my form designed in QT 4 ( windows)
This DOS executable is an exe file and takes certain switches and filenames (which I supply through lineedits)
Till now I was resorting to using .bat (executable) file where I used to write the whole command as I would have typed on the command prompt and then I execute that bat file with the help of system command . All this I do under a user defined function which is connected to a private slot activated by the click of a button.
This does work but is not correct and also gives bugs sometimes.
I tried the Qprocess thing but somehow it doesnot work.
I tried to adopt the code ( given by patrick08) which is used for seeing the file from the form as below .It does work for seeing file in it’s associated program.
The code for seeing ( say image ) file
{
ui.setupUi(this);
connect(ui.showimagefile, SIGNAL(clicked()), this, SLOT(showimagefile()));
}
void steg::showimagefile()
{
s1 << "url.dll,FileProtocolHandler" << ui.imagelineEdit->text() ;
p1.
startDetached(QString("rundll32.exe") , s1
);
}
steg::steg(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.showimagefile, SIGNAL(clicked()), this, SLOT(showimagefile()));
}
void steg::showimagefile()
{
QProcess p1;
QStringList s1;
s1 << "url.dll,FileProtocolHandler" << ui.imagelineEdit->text() ;
p1.startDetached(QString("rundll32.exe") , s1 );
}
To copy to clipboard, switch view to plain text mode
I adopted this for the exe program burp.exe with switches as -e filename1 filename2 -k keystring . The code I tried is as below
{
ui.setupUi(this);
connect(ui.encryptpushButton, SIGNAL(clicked()), this, SLOT(encrypt()));
}
void steg::encrypt()
{
char encrypt_comand[]= " -e ";
char key_comand[]= "-k=";
char space[]= " ";
s3 << space<< encrypt_comand<<ui.datalineEdit->text() <<space<< "coded.txt"<<space<<key_comand <<ui.passphraselineEdit->text();
p3.
startDetached(QString("burp.exe") , s3
);
}
steg::steg(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.encryptpushButton, SIGNAL(clicked()), this, SLOT(encrypt()));
}
void steg::encrypt()
{
char encrypt_comand[]= " -e ";
char key_comand[]= "-k=";
char space[]= " ";
QProcess p3;
QStringList s3;
s3 << space<< encrypt_comand<<ui.datalineEdit->text() <<space<< "coded.txt"<<space<<key_comand <<ui.passphraselineEdit->text();
p3.startDetached(QString("burp.exe") , s3 );
}
To copy to clipboard, switch view to plain text mode
But it doesnot work.
Your comments and guidance please.
Bookmarks