首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

注册表操作-RegEnumValue解决办法

2012-03-17 
注册表操作-RegEnumValue#includeafxwin.hvoidmain(){HKEYhKeyDWORDi0TCHARname[10]DWORDcbValueNam

注册表操作-RegEnumValue
#include   <afxwin.h>
void   main()
{
                HKEY   hKey;
DWORD     i=0;
TCHAR     name[10];  
DWORD   cbValueName   =32;
DWORD     datatype=REG_SZ;

LPBYTE   owner_Get=new   BYTE[80];  

                DWORD   cbData   =   80;
long   rect1=ERROR_SUCCESS;


                LPCTSTR   StrKey= "Software\\Microsoft\\Windows\\CurrentVersion\\Run ";
              long   ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,StrKey,NULL,KEY_ALL_ACCESS,&hKey);
if(ret0!=ERROR_SUCCESS)   //如果无法打开hKEY,则终止程序的执行  
{

printf( "错误:   无法打开有关的hKEY! ");
                                            return;
}


while(ERROR_SUCCESS==rect1)
{

        rect1=::RegEnumValue(hKey,i,name,   &cbValueName,NULL,
                &datatype,owner_Get,&cbData);
              i++;
printf( "%s\n ",name);
}
}
程序运行时   只能读出Software\\Microsoft\\Windows\\CurrentVersion\\Run下的部分子键,而不能全部读出,有没有人指点下错误在那里??  


[解决办法]
每次循环时,重置cbData

热点排行