RegGetValue与RegQueryValueEx

时间:2010-05-13 10:59:48

标签: windows registry

我有一个由其他人编码的程序。它有一个函数RegGetValue用作:

 uFuncReturnValue = RegOpenKeyExA(  HKEY_LOCAL_MACHINE, 
                                acSubKey, 
                                NULL, 
                                KEY_READ | KEY_WRITE,
                                    &hRegistry
                                    ); 

  //Store signature of the disk in the first 32 bytes of structVal
 if( uFuncReturnValue != ERROR_SUCCESS )
            {
            printf("Unable to open registry with error %u\n", uFuncReturnValue);
            exit(EXIT_FAILURE);;
            }

uFuncReturnValue = RegGetValueA( hRegistry, 
                        NULL, 
                        "\\DosDevices\\C:",  
                        RRF_RT_REG_BINARY, 
                        NULL, 
                        (LPVOID)&structVal, 
                        &dwSize
                        );

此代码块在Windows 7上运行良好,但在Windows XP(32位)上运行时返回错误。由于32位xp没有 RegGetValue 功能所以我试图使用 RegQueryValueEX ,但我在向这个函数传递参数时遇到了问题。我认为它应该用于某些事情:

uFuncReturnValue = RegQueryValueExA ( hRegistry, 
                                  "\\DosDevices\\J:",
                                  NULL,
                                  NULL,
                                  (LPBYTE) &structVal,
                                  &dwSize
                                  );

但是这里有些错误,因为代码编译成功,但是当我执行它时,我收到一条消息:

  

程序'(128)myProgram.exe:   Native'已退出代码1(0x1)。

有人可以帮助我吗?

0 个答案:

没有答案
相关问题