我的语句:
lr = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "\\SOFTWARE\\Microsoft\\Windows CE Services\\AutoStartOnConnect", 0,KEY_EXECUTE, &hKey);
if (lr != ERROR_SUCCESS)
{
AfxMessageBox("read sub key error!");
return ;
}
打开总是出错?注册表项目是直接从注册表里导出的,所以不会有错的
我的操作系统是winodws server 2003
还需要什么权限才能打开??

解决方案 »

  1.   

    GetlastError 看看是什么错误。
      

  2.   


    有没有这个键?我电脑上就没有[code=BatchFile]Res
    Unlike the RegCreateKeyEx function, the RegOpenKeyEx function does not create the specified key if the key does not exist in the registry.If your service or application impersonates different users, do not use this function with HKEY_CURRENT_USER. Instead, call the RegOpenCurrentUser function.A single registry key can be opened only 65534 times. When attempting the 65535th open operation, this function fails with ERROR_NO_SYSTEM_RESOURCES.[/code]另外
    我电脑上
    Windows CE Services这个键只要User就有读取的权限
      

  3.   

    FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER  | 
              FORMAT_MESSAGE_IGNORE_INSERTS  | 
             FORMAT_MESSAGE_FROM_SYSTEM,
             NULL,
             lr, 
             LANG_NEUTRAL,
             (LPTSTR) & lpBuffer,
              0 ,
             NULL );
    用这个来取得错误信息,说是《指定的路径无效》,但这个我是在注册表编辑器中用《复制项名称》来复制下来的。真搞不懂