clibrary.hpp
来自「bt848,bt878 a采集卡的探测」· HPP 代码 · 共 58 行
HPP
58 行
// Our class to dynamically load libraries!
#ifndef _CLIBRARY_HPP
#define _CLIBRARY_HPP
#include <windows.h>
class CLibrary {
protected:
HINSTANCE handle;
public:
// Constructors
CLibrary() : handle(HINSTANCE(0)) {}
CLibrary(LPTSTR libname) : handle(HINSTANCE(0)) {
Open(libname);
}
// To open/reopen a DLL
bool Open(LPTSTR libname) {
Close();
handle = ::LoadLibrary(libname);
return IsOpen();
}
// To get the address of a procedure
FARPROC GetProcAddress(LPTSTR libname) const {
return ::GetProcAddress(handle,libname);
}
FARPROC operator() (LPTSTR libname) const {
return ::GetProcAddress(handle,libname);
}
// To query if DLL was successfully loaded
bool IsOpen() const {
return (handle >= (HINSTANCE)32);
}
// To close the library
void Close() {
if (IsOpen()) {
::FreeLibrary(handle);
}
handle = (HINSTANCE)0;
}
// Destructor
~CLibrary() {
Close();
}
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?