Package com.jacob.activeX

Examples of com.jacob.activeX.ActiveXComponent


    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 {
View Full Code Here


    public void run() {
      try {
        ComThread.InitMTA();
        System.out.println("OnInit");
        String lang = "VBScript";
        sC = new ActiveXComponent("ScriptControl");
        sC.setProperty("Language", lang);
        ScriptTestErrEvents te = new ScriptTestErrEvents();
        de = new DispatchEvents(sC, te);
        System.out.println("sControl=" + sC);
        while (!quit) {
View Full Code Here

      } catch (InterruptedException ie) {
        // should we get this?
      }

      // get a thread-local Dispatch from sCon
      ActiveXComponent sc = new ActiveXComponent(sCon.toDispatch());

      // call a method on the thread-local Dispatch obtained
      // from the DispatchProxy. If you try to make the same
      // method call on the sControl object - you will get a
      // ComException.
      String scriptCommand = getSampleVPScriptForEval();
      Variant result = sc.invoke("Eval", scriptCommand);
      System.out.println("eval(" + scriptCommand + ") = " + result);
      script.quit();
      System.out.println("called quit");
    } catch (ComException e) {
      e.printStackTrace();
View Full Code Here

    public boolean OnInit() {
      try {
        System.out.println("OnInit");
        System.out.println(Thread.currentThread());
        String lang = "VBScript";
        sC = new ActiveXComponent("ScriptControl");

        // sCon can be called from another thread
        sCon = new DispatchProxy(sC);

        sC.setProperty("Language", lang);
View Full Code Here

   * @param classID
   *            The ClassID parameter passes the class identifier (CLSID) for
   *            an OLE object.
   */
    public void createUsingCLSID(String classID) {
        theDisp = new ActiveXComponent(classID);
    }
View Full Code Here

   * @param progID
   *            The progID parameter is the programmatic ID (ProgID) for the
   *            OLE automation server.
   */
   public void createUsingProgID(String progID) {
        theDisp = new ActiveXComponent(progID);
    }
View Full Code Here

   * @param classID
   *            The ClassID parameter passes the class identifier (CLSID) for
   *            an OLE object.
   */
    public void createUsingCLSID(String classID) {
        theDisp = new ActiveXComponent(classID);
    }
View Full Code Here

   * @param progID
   *            The progID parameter is the programmatic ID (ProgID) for the
   *            OLE automation server.
   */
   public void createUsingProgID(String progID) {
        theDisp = new ActiveXComponent(progID);
    }
View Full Code Here

   * the "Windows Task Manager"
   */
  public void testMultipleInstances() {
    ComThread.InitMTA();
    String mApplicationId = "Word.Application";
    ActiveXComponent instance1 = ActiveXComponent
        .createNewInstance(mApplicationId);
    ActiveXComponent instance2 = ActiveXComponent
        .createNewInstance(mApplicationId);
    try {
      Thread.sleep(10000);
    } catch (InterruptedException ie) {
    }
    instance1.invoke("Quit", new Variant[] {});
    instance2.invoke("Quit", new Variant[] {});
    ComThread.Release();

  }
View Full Code Here

   * "Windows Task Manager" to verify only one copy of MS Word is executing
   */
  public void testOnlyOneInstance() {
    ComThread.InitMTA();
    String mApplicationId = "Word.Application";
    ActiveXComponent instance1 = new ActiveXComponent(mApplicationId);
    ActiveXComponent instance2 = ActiveXComponent
        .connectToActiveInstance(mApplicationId);
    assertNotNull(instance2);
    try {
      Thread.sleep(10000);
    } catch (InterruptedException ie) {
View Full Code Here

TOP

Related Classes of com.jacob.activeX.ActiveXComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.