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导出与导入,并展示了如何在DLL文件中实现类成员函数以及在主程序中使用该DLL。此外,还给出了如何链接静态库文件的具体示例。

被折叠的 条评论
为什么被折叠?



