且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何向我的 C++ 应用程序添加一个简单的 API 以供 LabView 访问?

更新时间:2023-11-24 19:24:34

您在使用 DLL 时走在正确的轨道上.听起来,真正的技巧是决定您要使用哪种进程间通信 (IPC).选项有:套接字、管道、共享内存、同步对象(事件等)、文件、注册表等.

You are on the right track with a DLL. The real trick, it sounds like, will be deciding what sort of inter-process communication (IPC) you want to use. Options are: sockets, pipes, shared memory, synchronization objects (events, etc.), files, registry, etc.

一旦你决定,然后在你的可执行文件中实现一个监听器,以等待来自使用你的 DLL 的任何软件的传入 IPC 消息.

Once you decide that, then implement a listener within your executable to wait for incoming IPC messages from whatever software is using your DLL.

就 API 而言,您可以保持简单,就像您想要的那样.让 DLL 公开您的 4 或 5 个函数(确保您只使用本机数据类型,如 char* 和 long,以避免模块边界问题),然后这些将使用您的 IPC 机制与您正在执行的应用程序进行通信.

As far as the API is concerned, you can keep it simple just like you were wanting. Have the DLL expose your 4 or 5 functions (make sure you only use native data types, like char* and long, to avoid module boundary issues), and then those will use your IPC mechanism to communicate with your executing app.