明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2654|回复: 3

[LISP][LISP]如何调用Delphi编写的DLL?调试通不过

[复制链接]
发表于 2005-3-31 13:14 | 显示全部楼层 |阅读模式
不好意思,涉及多个概念,在VBA版也发了一份 使用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")
发表于 2005-3-31 19:53 | 显示全部楼层
这里是一个Vlisp调用VB的DLL的例子,参考一下。 ;;;************************************************************
;;; Filename: vbStringClass.LSP
;;; Author: David M. Stein
;;; Date: 3/2/02
;;; Purpose: Demonstrates use of imported DLL functions within
;;; Visual LISP functions
;;;************************************************************ (vl-load-com) (defun vbStrCat (string1 string2 / acad vbstrcls out)
(setq acad (vlax-get-acad-object))
(setq vbstrcls
(vlax-invoke-method acad
"getInterfaceObject" "vbStringClass.vbStrings"
)
)
(setq out
(vlax-invoke-method vbstrcls
"StrConcat" string1 string2
)
)
(vlax-release-object vbstrcls)
(vlax-release-object acad)
out
) (defun vbStrRev (string / acad vbstrcls out)
(setq acad (vlax-get-acad-object))
(setq vbstrcls
(vlax-invoke-method acad
"getInterfaceObject" "vbStringClass.vbStrings"
)
)
(setq out
(vlax-invoke-method vbstrcls
"StrReverse" string
)
)
(vlax-release-object vbstrcls)
(vlax-release-object acad)
out
) (defun vbStrVer ( / acad vbstrcls out)
(setq acad (vlax-get-acad-object))
(setq vbstrcls
(vlax-invoke-method acad
"getInterfaceObject" "vbStringClass.vbStrings"
)
)
(setq out
(vlax-invoke-method vbstrcls "StrVer")
)
(vlax-release-object vbstrcls)
(vlax-release-object acad)
out
)
 楼主| 发表于 2005-4-1 07:24 | 显示全部楼层
感谢


把VB DLL的源代码一起贴出来呀
发表于 2005-4-1 10:03 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-17 17:46 , Processed in 0.188081 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表