char path[200];
lstrcpy(path,"system\\currentcontrolset002\\services\\ccdd");
HKEY hRootKey;
LONG lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,path,0,KEY_ALL_ACCESS,&hRootKey);
if(lRet==ERROR_SUCCESS)
AfxMessageBox("open the key run success");
else
AfxMessageBox("open the key error!");以上代码,如果把path指定为system\\currentcontrolset\\services\\ccdd,就没有问题,如果是上面的,就会提示open the key error.
需要说明的是ccdd键我手工创建,肯定存在的。
请问大家是什么原因,会不会是权限问题,如果是权限问题,那么这段代码应该怎么写?

解决方案 »

  1.   

    long ret0=(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_READ, &hKEY));
      

  2.   

    为什么访问system\\currentcontrolset\\services\\ccdd,直接就可以成功呢?
      

  3.   

    char path[200];
    lstrcpy(path,"system\\currentcontrolset002\\services\\ccdd");
    HKEY hRootKey;
    LONG lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,path,0,KEY_READ,&hRootKey);
    if(lRet==ERROR_SUCCESS)
    AfxMessageBox("open the key run success");
    else
    AfxMessageBox("open the key error!");仍然不行。不过,上面两位是不是应该先试一下再说???,还这么多星呢!!!