📄 clibrary.hpp
字号:
// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -