void ShowInfo(HKEY hKey)
{
DWORD cSubKeys; // number of subkeys
DWORD cMaxSubKeyLen; // longest subkey name
DWORD cMaxClassLen; // longest class string
DWORD cValues; // number of value entries
DWORD cMaxValueNameLen; // longest value name
DWORD cMaxValueLen; // longest value data
DWORD cbSecurityDescriptor;// descriptor length
FILETIME ftLastWriteTime,ftLocalTime; // last write time
SYSTEMTIME sysTime;
char szClass[32];
DWORD dwClassLen=32;
DWORD ret;
ret=::RegQueryInfoKey(hKey,szClass,&dwClassLen,0,&cSubKeys, &cMaxSubKeyLen,
&cMaxClassLen,&cValues, &cMaxValueNameLen, &cMaxValueLen,
&cbSecurityDescriptor,&ftLastWriteTime);
::FileTimeToLocalFileTime(&ftLastWriteTime,&ftLocalTime);
::FileTimeToSystemTime(&ftLocalTime,&sysTime);
printf("%u/%u/%u %u:%u:%u\n",sysTime.wYear,sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute,sysTime.wSecond);
printf("%d,%d,%d\n",cMaxSubKeyLen,cMaxValueNameLen,cMaxValueLen);
}
最近在看几个注册表的api,RegQueryInfoKey()获取的其他值都正确,就是键值的最大长度 cMaxValueLen有问题,比实际的大好多,不知道怎么回事。一般是2倍多,有的很离谱是1024,求指导