📄 cmemory.hpp
字号:
// A Memory block class
#ifndef _CMEMORY_HPP
#define _CMEMORY_HPP
#include <windows.h>
// Be careful, there is no copy on write!! - All owners of references will see the changes!
class CString;
class CMemory {
protected:
// Our memory atom class
class CMemoryAtom {
protected:
void* block; // Memory block
UINT len; // Length of block
UINT refcount; // reference count
public:
CMemoryAtom(const UINT thelen = 0);
bool IsOk() const { return (block != NULL); }
bool ReSize(const UINT Amount);
UINT Size() const { return len; }
void* Ptr() const { return block; }
UINT RefCount() const { return refcount; }
void AddRef() { refcount++; }
bool Release();
~CMemoryAtom();
};
protected:
CMemoryAtom* atom; // My memory atom
public:
CMemory(const UINT thelen = 0) : atom(new CMemoryAtom(thelen)) {}
CMemory(CMemory& blk) : atom(0) { atom = blk.atom; atom->AddRef(); }
CMemory& operator=(CMemory& blk);
bool IsOk() const { return atom->IsOk(); }
bool ReSize(const UINT Amount) { return atom->ReSize(Amount); }
UINT Size() const { return atom->Size(); }
void* Ptr() const { return atom->Ptr(); }
~CMemory();
// Some useful fns
friend CMemory LoadBinaryResource(HINSTANCE instance,LPCTSTR res,LPCTSTR type = RT_RCDATA);
friend CMemory LoadBinaryFile(LPTSTR File);
friend CMemory LoadBinaryFile(CString& File);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -