怎么在dll中添加类,和使用dll中的类

dll.h 

#ifdef DLL_HIDDevice
 class _declspec(dllexport) CHIDDevice  //导出类
#else
 class _declspec(dllimport) CHIDDevice  //导入类po
#endif
{
public:
    DWORD GetConnectedDeviceNum(WORD vid, WORD pid);

}

dll.cpp

#define  DLL_HIDDevice
#include "HIDDevice.h"

DWORD CHIDDevice::GetConnectedDeviceNum(WORD vid, WORD pid)
{
            return deviceNum;
}

main.cpp

#include "dll.h"

#pragma comment(lib,"dll.lib")

CHIDDevice HID_Class;

int main (int argc, char* argv[])

{

     HID_Class.GetConnectedDeviceNum(...);

}

你可能感兴趣的:(怎么在dll中添加类,和使用dll中的类)