vb调用vc编写的dll文件,怎么调用在vc的dll中的类成员函数

vb调用vc编写的dll文件,如何调用在vc的dll中的类成员函数
前几天编写一个计算机与PLC通讯的dll文件,在VC下测试好用。但当时把所有的函数都写在一个类里面了,就是这些函数都是这个类的成员函数。
我想在vb里面调用这些函数,不知道怎么定义这些函数

这是我的dll的头文件,类名是COmronPC
C/C++ code


// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the OMRONPC_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// OMRONPC_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef OMRONPC_EXPORTS
#define OMRONPC_API __declspec(dllexport)
#else
#define OMRONPC_API __declspec(dllimport)
#endif
//
//This .dll is used to connect the PC and OMRON PLC;
//Created by Liu Daxin :liucgq@163.com
//用法:先创建一个COmronPC类,然后先用ComInit来初始化com口,再用PLCToConnect()链接plc
//然后可以在timer中加入ReadAndWritePLC()来完成读写
//
//
//
//
//
// This class is exported from the OmronPC.dll
class OMRONPC_API COmronPC {
public:
    void ReadAndWritePLC(char* readaddr="15",char readlenth='2',char* returnstr="");//前面的是需要读的首地址例如15.00,后面是返回的字符串
    void WriteOnOff(char* addr, int sta);
    void StopTimer();
    void StartWriteTimer(UINT mmtime=100);
    static void CALLBACK TimeProcSend(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2);
    void WriteSingleOnOffToPLC(char* addr,int sta);//addr为“1500”或“1715”等,可以打开或关闭相应的位
    void StopPLC();
    void PLCToConnect();
    void ReadFromPLC(char * str);
    void WriteToPLC(char OutDat[8]);
    HANDLE m_hCom;
    DCB dcb;
    void ComInit(char* port="COM1",long baurate=9600,int parityint=EVENPARITY,int bytsize=7,int stopbits=TWOSTOPBITS);
    //EVENPARITY 偶校验 ,NOPARITY 无校验 
    //MARKPARITY 标记校验   ODDPARITY 奇校验 
    //dcb.ByteSize = 7;//数据位 
    // ONESTOPBIT 1位停止位   
    //TWOSTOPBITS 2位停止位 
    //ONE5STOPBITS 1.5位停止位 
    COmronPC(void);
    char PLCReturn[30];
    // TODO: add your methods here.
private:
    char OutDat[21][4];
    unsigned long OutLong[21];
    HANDLE h_mutex;
    MMRESULT TimeID;
};

extern "C" OMRONPC_API int nOmronPC;

extern "C" OMRONPC_API int fnOmronPC(void);



我在vb中声明一个函数
VB code

Declare Sub ComInit Lib "OmronPC.dll" Alias "?ComInit@COmronPC@@QAEXPADJHHH@Z" ( _
ByRef comn As String, _
bute As Long, _
parity As Integer, _
butsize As Integer, _
stopbits As Integer)



一用就内存错误,什么什么只能为read的那种错误。
请问在vb中该怎么声明

------解决方案--------------------
恐怕不行。VB只能调用C++ Dll的导出函数吧。
如果是类成员函数,你得将Dll作为com interface。
将你的dll作为Com 模块使用吧。
------解决方案--------------------
http://topic.csdn.net/t/20051203/10/4435308.html

------解决方案--------------------
正好前段时间研究过。

方法一:首先需要动态调用,其次需要dll里的类成员函数是静态的。然后在调用时,类成员函数的名称是用c++的命名规则转换过的,所以调用时的类成员函数的名称会和c++编写源代码时的名称有所不同。

上面似乎说得很麻烦,那就说说简单的方法二:

在修改dll,在dll中用全局函数封装类成员函数的调用,然后导出这个全局函数(调出时可以用强制c编译,保证函数名称不发生变化,这样调用时比较方便),然后用动态调用方式,调用就可以了。
------解决方案--------------------
前一段时间也遇到过同样的问题,看看这个帖子吧
http://topic.csdn.net/u/20110623/14/6bbb50cc-c62e-4422-8fa6-37a766230697.html