vbScript到Delphi(错误:Variant Dispatch调用中不允许使用类型)

时间:2016-01-29 16:04:58

标签: delphi vbscript callback com

我正在尝试将VBscript转换为Delphi,但仍然坚持这一行:

test.init_library(myObj); //=> Type not allowed in Variant Dispatch call

如何修复错误? 你会不同地转换vbscript代码吗? 欢迎任何建议。 感谢

我正在尝试转换的一些vbscript代码:

Class myClass
  Public user
  public password
End class

dim myObj
Set myObj = New myClass
myObj.user = "userName"
myObj.password = "userPwrd"


set My_obj = wscript.CreateObject("COMtest","pref_")

Set init_lib = My_obj.get_init_library_obj

call init_lib.init_library(GetRef("Library_created"), myObj)

sub Library_created(p_Object)
  result = TypeName( p_Object) 
  MsgBox "class: " + result +" called for user: "+p_Object.user, 0, "COM Test"
end sub

德尔福代码:

procedure Test
var
  myObj : myClass;
  test : variant;
  ComObj : OleVariant;
  begin
    myObj := myClass.Create;
    myObj.user := 'userName';
    myObj.password := 'userPwrd';
    ComObj := CreateOleObject('COMtest');

    //Initialise obj
    test := ComObj.get_init_library_obj;

   test.init_library(myObj); //=> Type not allowed in Variant Dispatch call
end;

0 个答案:

没有答案