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

查看:327
本文介绍了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?

推荐答案

这通过写一个activex / COM包装为我的dll,我认为应该使它更容易链接到未来。在沼泽上启动会话,从好人那里了解如何调用COM的一些答案视觉Lisp。对于记录,它看起来像这样:

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天全站免登陆