Visual Lisp:如何在外部 C++ DLL 中调用函数 [英] Visual Lisp: how to call functions in external C++ DLL

查看:58
本文介绍了Visual Lisp:如何在外部 C++ DLL 中调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我编写的 C++ dll(本机,不是 .net),我想使用 Visual Lisp 中的功能.任何人都可以向我指出如何执行此操作的示例,或者至少要阅读哪些文档?

I have a C++ dll I have written (native, not .net), and I would like to use its functionality from Visual Lisp. Can anyone point me to an example of how to do this, or at least which bit of documentation to read?

推荐答案

我通过为我的 dll 编写一个 activex/COM 包装器解决了这个问题,我认为这应该可以使将来更容易链接.在沼泽上发起一个话题,从好人那里得到了一些关于如何从 Visual Lisp 调用 COM.为了记录,它看起来像这样:

I solved this by writing an activex/COM wrapper for my dll, which I think should make it easier to link to in future. Starting a thread on the swamp yielded some answers from nice people about how to call COM from Visual Lisp. For the record, it looks something like this:

//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

这篇关于Visual Lisp:如何在外部 C++ DLL 中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆