用RegEnumValure()函数时无法正确返回
编号:QA004586
建立日期: 2002年3月17日 最后修改日期:2002年3月17日
所属类别:
csc:
操作系统: windows
编程工具: vc++
问题: 用RegEnumValure()函数时无法正确返回,可否用C++写一些此方面的代码给我(我已经用RegOpenKeyEx()函数打开了),十分感激!!
水平: 中级
回答:
下面是一个简单的例子,你可以和你的程序比较一下:
/* open the key containing all the code page info */
lSuccess = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage", 0, KEY_QUERY_VALUE,
&hKey);
PERR(lSuccess == ERROR_SUCCESS, "RegOpenKeyEx");
while(TRUE)
{
cchValue = sizeof(szValue);
cbData = sizeof(szData);
/* get the next code page entry */
lSuccess = RegEnumValue(hKey, iValue++, szValue, &cchValue, NULL,
&dwType, szData, &cbData);
if (lSuccess == ERROR_NO_MORE_ITEMS)
break;
if (!szData[0]) /* if value data is NULL, it's an invalid code page; skip */
continue;
if (!(uiCP = atoi(szValue))) /* if value name is not a number, skip */
continue;
sprintf(szTemp, "\n\nCodepage: %s", szValue);
myPuts(hConOut, szTemp);
/* set code page and display all 256 chars on the console */
showCP(hConOut, uiCP);
}
此问题由李海回答。
| |
|
|
| |
|
|