Visual Lisp:如何调用外部c++ DLL中的函数

Visual Lisp: how to call functions in external C++ DLL

本文关键字:c++ 外部 DLL 函数 调用 Lisp 何调用 Visual      更新时间:2023-10-16

我有一个我写的c++ dll(原生的,不是。net),我想从Visual Lisp中使用它的功能。谁能给我举个例子,告诉我如何做到这一点,或者至少应该阅读哪个文档?

我通过为我的dll编写activex/COM包装器来解决这个问题,我认为这应该使将来更容易链接到。在沼泽上启动一个线程,得到了一些关于如何从Visual Lisp调用COM的好朋友的回答。为了记录,它看起来像这样:

//in c++... (header and IDL file also needed)
hresult timestwo(double in,double* out)
{
  *out = in*2;
  return S_OK;
}
;; in Lisp...
(vl-load-com)
(setq myinstance (vlax-create-object "mycomwrapperdll.mycomwrapperclass"))
(setq num 12.34)
(vlax-invoke-method myinstance 'timestwo num 'newnum)
(vlax-release-object myinstance)
;; newnum now contains 24.68

使用acedDefun()和acedRegFunc() API调用将本地c++代码暴露给AutoLisp。

这是Autodesk编程论坛上的一个讨论,问的正是你的问题。