Menu

How can I use a Type from a DLL?

2005-03-01
2013-04-17
  • Nobody/Anonymous

    I've tried this wonderful bridge to COM and it's very helpful.
    Now i have to use a dll function (the dll is written in vb) that use a dll type but i don't know how to do with JCom. It's impossibile to go on without an english doc!
    This is a VB code that test the dll and I've to emulate in Java.
    Thank in advance!

            Dim cls As New Lotti32.clsLotti

            ' new type
            Dim factory As Lotti32.factoryType
            res = cls.GetFactory(factory)

     
    • Philippe Ombredanne

      It hass to be a COM object. Then it can be used an any COM object.
      Check the VBCom.java example for that: something like:
      Dim cls As New Lotti32.clsLotti 
      -> becomes ->
      IDispatch vbcom = new IDispatch(rm, "Lotti32.clsLotti");

      Dim factory As Lotti32.factoryType
      ->becomes->
      Object[] param = new Object[] { somethingLikeYourFactoryType };

      res = cls.GetFactory(factory)
      ->becomes ->
      Object o = vbcom.method("GetFactory", param);

      Or something like that.

      Beware or returned types and how you cast.
      Check also the Excel implementation for hints.

       
    • Nobody/Anonymous

      First of all: THANK YOU! but...
      I tried to implement a class like the Factory type as you said but it doesn't work. I still receive an error message:

      "..JComException: Invalid argument(index=0)
      ....
      ERROR!!! cannot convert jobject to VARIANT."

      I tried to extends IDispatch to this class(class FactoryType), and this is the error:

      "DISP_E_TYPEMISMATCH 0"

      The class FactoryType has the same property of the DLL VB Type (simple a string) and i've just tried unluckly to implements get/set method for this property.

      If this can help you, this is the print of the funcDesc of the getFactory()

      "FUNC GetDitta([in][out]VT_PTR+VT_USERDEFINED(3000ce4):DittaType aty_Ditta)VT_I2"

      (as you see a Short object is required as result and the parameter is the userdefined FactoryType)

      thank u again!!!

       

Log in to post a comment.

MongoDB Logo MongoDB