jgirlich
23rd May 2013, 17:18
Hi,
I'm trying to call a VBScript from within Qt and set up a small test application:
#include <QAxScriptManager>
#include <QDebug>
int main(int argc, char *argv[])
{
QAxScriptManager m_manager;
QAxScript *m_helloWorld = m_manager.load("C:\\test.vbs", "HelloWorld");
if (m_helloWorld)
m_helloWorld->call("helloWorld");
else
qDebug() << "didn't load";
}
The VBScript is at the right place on C:\test.vbs and looks like this:
Function helloWorld()
msgbox("Hello World")
End Function
Now when I compile and run this I don't get a QAxScript back from the QAxScriptManager. Stepping through the code I learned that the file is read and a QAxScript object created, but in the load function on it its isValid() function returns false because the internal member 'engine' is not set and therefore later the object is discarded and a NULL pointer returned. But I couldn't find where 'engine' would ever be set.
Can you please help me understand what I am doing wrong?
Or give me some example code?
Cheers
Jan
Edited: typo
I'm trying to call a VBScript from within Qt and set up a small test application:
#include <QAxScriptManager>
#include <QDebug>
int main(int argc, char *argv[])
{
QAxScriptManager m_manager;
QAxScript *m_helloWorld = m_manager.load("C:\\test.vbs", "HelloWorld");
if (m_helloWorld)
m_helloWorld->call("helloWorld");
else
qDebug() << "didn't load";
}
The VBScript is at the right place on C:\test.vbs and looks like this:
Function helloWorld()
msgbox("Hello World")
End Function
Now when I compile and run this I don't get a QAxScript back from the QAxScriptManager. Stepping through the code I learned that the file is read and a QAxScript object created, but in the load function on it its isValid() function returns false because the internal member 'engine' is not set and therefore later the object is discarded and a NULL pointer returned. But I couldn't find where 'engine' would ever be set.
Can you please help me understand what I am doing wrong?
Or give me some example code?
Cheers
Jan
Edited: typo