ComThread.InitSTA(true);
DispatchEvents de = null;
try {
String lang = "VBScript";
ActiveXComponent sC = new ActiveXComponent("ScriptControl");
sC.setProperty("Language", lang);
ScriptTestErrEvents te = new ScriptTestErrEvents();
de = new DispatchEvents(sC, te);
if (de == null) {
System.out
.println("null returned when trying to create DispatchEvents");
}
Variant result;
result = sC.invoke("Eval", getSampleVPScriptForEval());
// call it twice to see the objects reused
result = sC.invoke("Eval", getSampleVPScriptForEval());
// call it 3 times to see the objects reused
result = sC.invoke("Eval", getSampleVPScriptForEval());
System.out.println("eval(" + getSampleVPScriptForEval() + ") = "
+ result);
} catch (ComException e) {
e.printStackTrace();
} finally {