如何向我的 C++ 应用程序添加一个简单的 API 以供 LabView 访问? [英] How to add a simple API to my C++ application for access by LabView?

查看:23
本文介绍了如何向我的 C++ 应用程序添加一个简单的 API 以供 LabView 访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 C++ (Visual Studio 6.0) 编写的数据采集程序.一些客户希望从他们自己的定制软件或 LabView 控制软件.我想提出一个带有 dll 的简单 API,我可以将其分发给他们,并希望获得一些有关如何入门的提示.这将是非常基本的,可能是 4 或 5 个命令.我的 DAQ 程序仍将在同一台机器上的自己的窗口中运行,我只想将其设置为由另一个程序控制.

I have a data acquisition program written in C++ (Visual Studio 6.0). Some clients would like to control the software from their own custom software or LabView. I would like to come up with a simple API with a dll I can distribute to them and would like some tips on how to get started. This is going to be VERY basic, maybe 4 or 5 commands. My DAQ program will still be running in its own window on the same machine, I would just like to set it up to be controlled from another program.

推荐答案

您在使用 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.

这篇关于如何向我的 C++ 应用程序添加一个简单的 API 以供 LabView 访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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