可不可以把一个DLL做成类,然后调用DLL中的函数[问题]
我现在有一个动态库hybird.dll,我要动态调用它里面的函数,除了静态和动态调用外,能不能把它做成一个类,放在一个头文件中如:hybird_dll.h中,具体文件实现如下:
#include "stdafx.h"
class HyBird
{
//hybird.dll函数声明
public:
HINSTANCE lib;
typedef bool (WINAPI* SETCOM)(int x, int y, int z);
typedef bool (WINAPI* OPENCOMMPORT)(void);
//// 函数事例化
SETCOM setCom;
OPENCOMMPORT openCommPort;
///调用dll
lib=LoadLibrary("hybird.dll");
if (lib==NULL)
{
AfxMessageBox("hybird.dll调用失败");
return ;
}
setCom=(SETCOM)GetProcAddress(lib,"setCom");
openCommPort=(OPENCOMMPORT)GetProcAddress(lib,"openCommPort");
};
但是在别处用的时候,老是提示错误:
error C2258: illegal pure syntax, must be '= 0'
error C2501: 'lib' : missing storage-class or type specifiers
error C2501: 'setCom' : missing storage-class or type specifiers
请知道的朋友指点迷津,多谢了