C2504: base class undefinedITeye - AG环亚娱乐集团

C2504: base class undefinedITeye

2019-01-10 15:52:00 | 作者: 幻巧 | 标签: 安装文件,项目,开发 | 浏览: 2203

error C2504: CObject : base class undefined 今日编写的类:rnCRegistry.h文件:rn#include afxwin.h rn#include rn#include rn#include rnclass CRegistry :public CObjectrnrnpublic:rn CRegistry(HKEY hKey=HKEY_LOCAL_MACHINE);rn ~CRegistry();rn//对注册表的根本操作rnpublic:rn BOOL RegOpen(LPCTSTR lpSubKey);rn void Close();rn BOOL CreateKey(LPCTSTR lpSubKey);rn BOOL DeleteValue(LPCTSTR lpValueName);rn BOOL DeleteKey(HKEY hKey,LPCTSTR lpSubKey);rn//对注册表的读写rnpublic:rn BOOL Write(LPCTSTR lpSubkey,int nVal);rn BOOL Write(LPCTSTR lpSubKey,DWORD dwVal);rn BOOL Write(LPCTSTR lpSubKey,LPCTSTR lpVal);rn BOOL Read(LPCTSTR lpValue,int* nVal);rn BOOL Read(LPCTSTR lpValue,DWORD* dwVal);rn BOOL Read(LPCTSTR lpValue,LPCTSTR* lpVal);rnprotected:rn HKEY m_hKey;rnrnCRegistry.cpp文件:rn#include windows.h rn#include CRegistry.h rnCRegistry::CRegistry(HKEY hKey)rnrn m_hKey=hKey;//需求进行操作的根键rnrnCRegistry::~CRegistry()rnrn Close();rnrnBOOL CRegistry::RegOpen(LPCTSTR lpSubKey)rnrn ASSERT(m_hKey);rn ASSERT(lpSubKey);rnrn HKEY hKey;rn long iRet=RegOpenKeyEx(m_hKey,lpSubKey,0,KEY_ALL_ACCESS, hKey);rn if(iRet==ERROR_SUCCESS)rn rn m_hKey=hKey;rn return TRUE;rn rn return FALSE;rnrnvoid CRegistry::Close()rnrn if(m_hKey)rn rn RegCloseKey(m_hKey);rn m_hKey=NULL;rn rnrnBOOL CRegistry::CreateKey(LPCTSTR lpSubKey)rnrn ASSERT(m_hKey);rn ASSERT(lpSubKey);rnrn HKEY hKey;rn DWORD dwType;rn long iRet=RegCreateKeyEx(m_hKey,lpSubKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL, hKey, dwType);rn if(iRet==ERROR_SUCCESS)rn rn m_hKey=hKey;rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::DeleteValue(LPCTSTR lpValueName)rnrn ASSERT(m_hKey);rn long iRet=RegDeleteValue(m_hKey,lpValueName);rn if(iRet==ERROR_SUCCESS)rn rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::DeleteKey(HKEY hKey,LPCTSTR lpSubKey)rnrn ASSERT(m_hKey);rn long iRet=RegDeleteKey(m_hKey,lpSubKey);rn if(iRet==ERROR_SUCCESS)rn rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::Write(LPCTSTR lpSubKey,int nVal)rn//将指定的值写入指定的键rn ASSERT(m_hKey);rn ASSERT(lpSubKey);rn rn DWORD dwValue;rn dwValue=(DWORD)nVal;rn long iRet=RegSetValueEx(m_hKey,lpSubKey,0,REG_DWORD,(const BYTE*) dwValue,sizeof(DWORD));rn if(iRet==ERROR_SUCCESS)rn rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::Write(LPCTSTR lpSubKey,DWORD dwVal)rnrn ASSERT(m_hKey);rn ASSERT(lpSubKey);rnrn long iRet=RegSetValueEx(m_hKey,lpSubKey,0,REG_DWORD,(const BYTE*) dwVal,sizeof(DWORD));rn if(iRet==ERROR_SUCCESS)rn rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::Write(LPCTSTR lpSubKey,LPCTSTR lpVal)rnrn ASSERT(m_hKey);rn ASSERT(lpSubKey);rn ASSERT(lpVal);rnrn long iRet=RegSetValueEx(m_hKey,lpSubKey,0,REG_SZ,(const BYTE*)lpVal,strlen(lpVal)+1);rn if(iRet==ERROR_SUCCESS)rn rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::Read(LPCTSTR lpValue,int* nVal)rnrn ASSERT(m_hKey);rn ASSERT(lpValue);rnrn DWORD dwType;rn DWORD dwSize=sizeof(DWORD);rn DWORD buffer;rn long iRet=RegQueryValueEx(m_hKey,lpValue,0, dwType,(BYTE*) buffer, dwSize);rn if(iRet==ERROR_SUCCESS)rn rn *nVal=(int)buffer;rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::Read(LPCTSTR lpValue,DWORD* dwVal)rnrn ASSERT(m_hKey);rn ASSERT(lpValue);rnrn DWORD dwType;rn DWORD dwSize=sizeof(DWORD);rn DWORD buffer;rn long iRet=RegQueryValueEx(m_hKey,lpValue,0, dwType,(BYTE*) buffer, dwSize);rn if(iRet==ERROR_SUCCESS)rn rn *dwVal=buffer;rn return TRUE;rn rn return FALSE;rnrnBOOL CRegistry::Read(LPCTSTR lpValue,LPCTSTR* lpVal)rnrn ASSERT(m_hKey);rn ASSERT(lpValue);rnrn DWORD dwType;rn DWORD dwSize=200;rn char szString[2550];rnrn long iRet=RegQueryValueEx(m_hKey,lpValue,0, dwType,(BYTE*)szString, dwSize);rn if(iRet==ERROR_SUCCESS)rn rn *lpVal=szString;rn return TRUE;rn rn return FALSE;rnrnrn编译呈现如下过错:rnd:\安装文件2\vc\2010 vc项目开发\cregistry\cregistry.h(4) : error C2504: CObject : base class undefinedrnd:\安装文件2\vc\2010 vc项目开发\cregistry\cregistry.cpp(3) : error C2143: syntax error : missing ; before PCH creation pointrnd:\安装文件2\vc\2010 vc项目开发\cregistry\cregistry.cpp(13) : error C2065: ASSERT : undeclared identifierrn履行 cl.exe 时犯错.rnrn讨教高手

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表AG环亚娱乐集团立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章

阅读排行

  • 1

    oxygenxml.oxygenITeye

    插件,生成器,代码
  • 2

    JVM参数装备大全ITeye

    信息,打印,前后
  • 3

    ThreadITeye

    先后,正常,作业
  • 4
  • 5

    vba upgradeITeye

    文件,程序,晋级
  • 6

    java 多线程ITeye

    线程,作业,内存
  • 7
  • 8

    ClassLoaderITeye

    运用,文件,办法
  • 9
  • 10

    手机号码校验合法性ITeye

    代表,必定,第二位