使用VisualLISP调用Delphi编写的DLL,调试通不过
生成DLL完整的Delphi代码,生成的DLL文件名为MyDll.dll library MyDll; // library 为 DLL uses SysUtils,Classes;
function AddOne(i:integer):integer;stdcall; // 一般需要导出的函数都要是 stdcall begin Result:=i+1; end;
exports // 导出表 AddOne;
begin end.
调用DLL的LISP代码 (vl-load-com) (defun c:testdll (/ a re) (setq a (vla-getinterfaceobject (vlax-get-acad-object) "MyDll" ;1、这里肯定有问题!!! ) ; Delphi没有类模块,对照VB不知该怎么改动 ) (setq re (vlax-invoke-method ;2、是不是这样获得返回值? a "AddOne" 100 ;3、是不是这样传递参数? ) ) (vlax-release-object a) (princ re) (princ) )
运行提示 错误: Automation 错误。 加载应用程序时出现问题
附VBA帮助中关于GetInterfaceObject说明 Accepts a program ID and attempts to load it into AutoCAD as an in-process server.
RetVal = object.GetInterfaceObject(ProgID)
Object Application The object or objects this method applies to.
ProgID String; input-only The program ID of the interface object to return.
RetVal Object The interface object matching the program ID.
Example中ProgID给了个令人摸不着头脑的例子 Dim poly As Object Set poly = ThisDrawing.Application.GetInterfaceObject("Polycad.Application")
我的QQ:10824256