CString pathString;
char subChar[MAX_BUFF_SIZE] = "Software\\netmsg\\" ;
HKEY hKey;
long retLong;
retLong = ::RegOpenKeyEx(
HKEY_CURRENT_USER, // handle to open key
subChar, // subkey name
0, // reserved
KEY_ALL_ACCESS, // security access mask
&hKey // handle to open key
);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("打开注册表出错1!");
}
memset(subChar,0,sizeof(subChar));
LPBYTE subLPBYTE = new BYTE[80];
DWORD subDword = 80;
retLong = ::RegQueryValueEx(hKey,"ClientSet",NULL,NULL,subLPBYTE,&subDword);
if (ERROR_SUCCESS != retLong )
{
char subKeyBuffer[MAX_BUFF_SIZE] = "ClientSet";
HKEY subKey;
DWORD dwFunc;
retLong = ::RegCreateKeyEx(hKey,
(LPCTSTR)subKeyBuffer,//要创建的子键名字的地址
0,//保留值,必须为0
(LPTSTR)NULL,
KEY_ENUMERATE_SUB_KEYS,
KEY_CREATE_SUB_KEY,
(LPSECURITY_ATTRIBUTES)NULL,
&subKey,
&dwFunc);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("创建子键出错!");
}
// ::RegCloseKey(hKey);// retLong = ::RegOpenKeyEx(
// HKEY_CURRENT_USER, // handle to open key
// subChar, // subkey name
// 0, // reserved
// KEY_ALL_ACCESS, // security access mask
// &hKey // handle to open key
// );
// if (ERROR_SUCCESS != retLong)
// {
// AfxMessageBox("打开注册表出错1!");
// }
LPCTSTR filePath = "e:\\dfg.db";
char subKeyBuffer1[MAX_BUFF_SIZE] = "dbpath";
DWORD cbData = strlen(filePath)+1;
retLong = ::RegSetValueEx(
subKey,
"dbpath",
0,
REG_SZ,
(LPBYTE)filePath,
cbData);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("设置子键值出错2!");
}=================================================
总是提示 设置子键值出错2 ,RegSetValueEx 运行不成功!
char subChar[MAX_BUFF_SIZE] = "Software\\netmsg\\" ;
HKEY hKey;
long retLong;
retLong = ::RegOpenKeyEx(
HKEY_CURRENT_USER, // handle to open key
subChar, // subkey name
0, // reserved
KEY_ALL_ACCESS, // security access mask
&hKey // handle to open key
);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("打开注册表出错1!");
}
memset(subChar,0,sizeof(subChar));
LPBYTE subLPBYTE = new BYTE[80];
DWORD subDword = 80;
retLong = ::RegQueryValueEx(hKey,"ClientSet",NULL,NULL,subLPBYTE,&subDword);
if (ERROR_SUCCESS != retLong )
{
char subKeyBuffer[MAX_BUFF_SIZE] = "ClientSet";
HKEY subKey;
DWORD dwFunc;
retLong = ::RegCreateKeyEx(hKey,
(LPCTSTR)subKeyBuffer,//要创建的子键名字的地址
0,//保留值,必须为0
(LPTSTR)NULL,
KEY_ENUMERATE_SUB_KEYS,
KEY_CREATE_SUB_KEY,
(LPSECURITY_ATTRIBUTES)NULL,
&subKey,
&dwFunc);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("创建子键出错!");
}
// ::RegCloseKey(hKey);// retLong = ::RegOpenKeyEx(
// HKEY_CURRENT_USER, // handle to open key
// subChar, // subkey name
// 0, // reserved
// KEY_ALL_ACCESS, // security access mask
// &hKey // handle to open key
// );
// if (ERROR_SUCCESS != retLong)
// {
// AfxMessageBox("打开注册表出错1!");
// }
LPCTSTR filePath = "e:\\dfg.db";
char subKeyBuffer1[MAX_BUFF_SIZE] = "dbpath";
DWORD cbData = strlen(filePath)+1;
retLong = ::RegSetValueEx(
subKey,
"dbpath",
0,
REG_SZ,
(LPBYTE)filePath,
cbData);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("设置子键值出错2!");
}=================================================
总是提示 设置子键值出错2 ,RegSetValueEx 运行不成功!
解决方案 »
- error C2146: 语法错误 : 缺少“;”(在标识符“m_LoginDlg”的前面)
- 折腾很久了,快发疯了呀,求助,有错误找不到原因!
- Visual Studio的问题。
- 请问:有没有将数转化成字符的函数?
- 关于activex
- 紧急求助:如何在安全模式下激活xp home版,正常启动进不去,为什么??在线等待!
- ADO:怎样获得系统日期并存入Access数据库
- 如何获得窗口句柄
- 有谁在华储买过书?我想买,不知道信誉怎么样?
- 2000下如何让程序不出现在任务管理器中阿??
- Property or Method not supported by layers of this type.
- 界面最大化问题?
char subChar[MAX_BUFF_SIZE] = "Software\\netmsg\\" ;
HKEY hKey;
long retLong;
retLong = ::RegOpenKeyEx(
HKEY_CURRENT_USER, // handle to open key
subChar, // subkey name
0, // reserved
KEY_ALL_ACCESS, // security access mask
&hKey // handle to open key
);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("打开注册表出错1!");
}
memset(subChar,0,sizeof(subChar));
LPBYTE subLPBYTE = new BYTE[80];
DWORD subDword = 80;
retLong = ::RegQueryValueEx(hKey,"ClientSet",NULL,NULL,subLPBYTE,&subDword);
if (ERROR_SUCCESS != retLong )
{
char subKeyBuffer[MAX_BUFF_SIZE] = "ClientSet";
HKEY subKey;
DWORD dwFunc;
retLong = ::RegCreateKeyEx(hKey,
(LPCTSTR)subKeyBuffer,//要创建的子键名字的地址
0,//保留值,必须为0
(LPTSTR)NULL,
KEY_ENUMERATE_SUB_KEYS,
KEY_CREATE_SUB_KEY,
(LPSECURITY_ATTRIBUTES)NULL,
&subKey,
&dwFunc);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("创建子键出错!");
}
::RegCloseKey(hKey); retLong = ::RegOpenKeyEx(
subKey, // handle to open key
"", // subkey name
0, // reserved
KEY_ALL_ACCESS, // security access mask
&hKey // handle to open key
);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("打开注册表出错2!");
}
LPCTSTR filePath = "e:\\dfg.db";
char subKeyBuffer1[MAX_BUFF_SIZE] = "dbpath";
DWORD cbData = strlen(filePath)+1;
retLong = ::RegSetValueEx(
subKey,
"dbpath",
0,
REG_SZ,
(LPBYTE)filePath,
cbData);
if (ERROR_SUCCESS != retLong)
{
AfxMessageBox("设置子键值出错2!");
}
==============================================
加了 OPEN 还是不行呀?