com - Executing cscript using IActiveScript with C++ -


i'm trying execute script using cscript iactivescriptparse , parsescripttext reason error: e_unexpected.

this article has helped me lot. i'm using getengineguid function in code.

the code below i've tried. prints:

-2147418113 -2147418113 

meaning activescriptparse->parsescripttext returns e_unexpected. doing wrong?

#include <iostream> #include <windows.h> #include <objbase.h> #include <activscp.h>  using namespace std;  int main(int argc, char* argv[]) {     coinitialize(null);     guid guidbuffer;      // find script engine use files end .js extension.     // implemented in article linked to.     getengineguid(".js", &guidbuffer);      iactivescript *activescript;     cocreateinstance(guidbuffer, 0, clsctx_all,                      iid_iactivescript,                      (void **)&activescript);     iactivescriptparse *activescriptparse;     activescript->queryinterface(iid_iactivescriptparse,                                  (void **)&activescriptparse);     activescriptparse->initnew();      excepinfo ei ={};     variant result;     cout << e_unexpected << endl;     cout << activescriptparse->parsescripttext(olestr("(new date()).gettime()"), null,                                                null, null, 0, 0, scripttext_isexpression,                                                &result, &ei) << endl;     activescriptparse->release();      return 0; } 

thanks lot!

igor tandetnik's comment pointed me correct direction.

the article used shows how setscriptsite it's written in c. question: how load & call vbscript function within c++ has helpful answer.

as answer says, should define class has @ least iactivescriptsite , iactivescriptsitewindow interfaces.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -