想用VC编写封装从串口数据通信的DLL,由于考虑到有多个串口同时通信,该DLL需要是面向对象的。目前已经有一个VC可以调用的面向对象DLL,不知道VB该如何调用,以下是接口。#pragma once#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif#include "resource.h" // main symbols
// CPDICCommApp
// See PDICComm.cpp for the implementation of this class
//#define CAN_MSG_PAYLOAD_SIZE 4
#define CAN_MSG_MAX_ID_VALUE 2031
typedef int (*PROCESS_REPORT_HANDLE)(UINT pReportID, int len, UCHAR *pReportData);class AFX_EXT_CLASS CPDICComm
{
public:
//构造函数,初始化成员变量
CPDICComm(); //打开串口
int Open(CString strPortName, int nPortBaud); //关闭串口
int Close(); //发送数据至总线, pReportData以字为单位的内存指针, nReportSize发送字数最多4字, bWaitAck是否等待设备ACK
int Write(UINT pReportID, UCHAR *pReportData, int nReportSize, bool bWaitAckt); //进入监听模式
int StartMonitoring(); //设置上报消息处理回调
void SetProcessHandle(PROCESS_REPORT_HANDLE handle);private:
void *reserved1;
void *reserved2;
int reserved3;
int reserved4;
int reserved5;
int reserved6;
int reserved7;
bool reserved8;
bool reserved9;
WORD reserved10;
};
类似这样的接口VB如何调用?
#error "include 'stdafx.h' before including this file for PCH"
#endif#include "resource.h" // main symbols
// CPDICCommApp
// See PDICComm.cpp for the implementation of this class
//#define CAN_MSG_PAYLOAD_SIZE 4
#define CAN_MSG_MAX_ID_VALUE 2031
typedef int (*PROCESS_REPORT_HANDLE)(UINT pReportID, int len, UCHAR *pReportData);class AFX_EXT_CLASS CPDICComm
{
public:
//构造函数,初始化成员变量
CPDICComm(); //打开串口
int Open(CString strPortName, int nPortBaud); //关闭串口
int Close(); //发送数据至总线, pReportData以字为单位的内存指针, nReportSize发送字数最多4字, bWaitAck是否等待设备ACK
int Write(UINT pReportID, UCHAR *pReportData, int nReportSize, bool bWaitAckt); //进入监听模式
int StartMonitoring(); //设置上报消息处理回调
void SetProcessHandle(PROCESS_REPORT_HANDLE handle);private:
void *reserved1;
void *reserved2;
int reserved3;
int reserved4;
int reserved5;
int reserved6;
int reserved7;
bool reserved8;
bool reserved9;
WORD reserved10;
};
类似这样的接口VB如何调用?
如果有这样跨语言的复用二进制对象的办法,那COM就没必要出现了。
1种情况可以有类似VB调用API的VC导出方法, 自己根据VB调用API去查关键字吧
2种是VC写成COM组件, 要实现IDispatch接口, VB就可以以IDispatch定义的VB方法名调用了.