Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Trouble with IDispatch Out parameter.

  • Dmitry Bukeev
    Dmitry Bukeev

    Hello all.

    I have serious problem call RequestStateChange Method of the Msvm_ComputerSystem Class of WMI hyper-v.

    method syntax is
    uint32 RequestStateChange(
         uint16 RequestedState,
        CIM_ConcreteJob REF Job,
         datetime TimeoutPeriod

    I use next code

          JIVariant jobref=  JIVariant.OUTPARAMforType(JIVariant.class,false);
          JIVariant returnParams = vm.callMethodA("RequestStateChange",new Object[ {3,jobref});
          System.out.println ("jobref is =" + (JIVariant)returnParams).getObjectAsVariant());

    Andt print is
    jobref is =[[[Type: 1 , ]]]
    And Variant type is BSTR at this case.
    But I need get IDispatch for next monitoring of thsi job.

    I also try  type IDispatch for out parameter like
          JIVariant jobref1=  JIVariant.OUT_IDISPATCH();
    But it generate exception for call RequestStateChange method
       org.jinterop.dcom.common.JIException: The server threw an exception.

    Please, help me obtain out parameter as IDispatch for next monitoring of job.

    With best regards

  • Hi,
         I think what you have is a moniker , you can use the "ExecMethod" of IWbemServices and execute a method on that moniker . Can you try that and see if it works ?

    best regards,

  • Dmitry Bukeev
    Dmitry Bukeev

    Vikram, thank your answer :)

    I was busy very much and can come back to this work now only.

    I walk all my code and MSDN resource for have more expirience with WMI and Hyper-V classes and interfaces.
    Now I have more knowledge about asynchronous, synchronous and semisynchronous method call for some Hyper-V classes :)
    And I think I must receive reference to CIM_ConcreteJob as described at MSDN
    And my print of returned by this method value describe this.
    But my attempts receive reference to CIM_ConcreteJob  are  not successfull now.
    And I can't find way to execute method RequestStateChange of Msvm_ComputerSystem Class as you recommended for me with moniker, sorry.

    Have you any idea to get reference to CIM_ConcreteJob from method RequestStateChange ?

    With best regards

  • rwy

    Hello, could any of you post an example of using ExecMethod, if you have done it successfully? Thanks.