比如,现在我用vb写个类;class Test public Test As String function Echo() AS String Echo = Test end function end class保存为Test.cls,工程为Test,生成后是 test.test,编译的dll 用命令行程序RegSvr32打开注册。delphi 中 new Application ,然后在你的Form中的uses 加入 ComObjok,建立它var ObjCom:Variant; begin ObjCom := CreateOLEObject('Test.test'); ObjCom.Test := 'Hello vb!'; Showmessage(ObjCom.Echo); ObjCom := null; end;//代码很简单,随手写的不免有错误之处,见谅,希望对你有用
1、使用CreateObject函数动态地建立对象。在Delphi的Demos\ActiveX\OleAuto\AutoCtrl目录中有这方面的例子,它是调用Word的例子。
2、使用Project|Import Type Library项,然后从目前系统中注册的所有DLL中找到你的DLL,这样Delphi就会生成一个.pas文件,你可以调用这个单元来使用ActiveX DLL中的类。
public Test As String
function Echo() AS String
Echo = Test
end function
end class保存为Test.cls,工程为Test,生成后是 test.test,编译的dll 用命令行程序RegSvr32打开注册。delphi 中 new Application ,然后在你的Form中的uses 加入 ComObjok,建立它var ObjCom:Variant;
begin
ObjCom := CreateOLEObject('Test.test');
ObjCom.Test := 'Hello vb!';
Showmessage(ObjCom.Echo);
ObjCom := null;
end;//代码很简单,随手写的不免有错误之处,见谅,希望对你有用
你可以先在当前目录搜索这个dll文件,然后用代码注册它一次就ok