gpt4 book ai didi

c++ - RegKeyValue 返回无意义的数据

转载 作者:行者123 更新时间:2023-11-30 01:23:51 32 4
gpt4 key购买 nike

char value[255];
DWORD BufferSize = 8192;

RegGetValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"ProductName", RRF_RT_ANY, NULL, &value, &BufferSize);

cout << value;

RegKeyValue() 运行后,看起来值是

    value   0x0034f50c "ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ...  char[255]

这是怎么回事?

注意:RegKeyValue() 返回 0

最佳答案

这里有两个问题。

  1. 确保返回值RegGetValueERROR_SUCCESS。如果不是,例程失败。此外,您还可以查看写入到 BufferSize 中的内容,因为 RegGetValue 指定写入的字节数。

  2. 您传入定义为 char value[255]; 的缓冲区,然后将其长度指定为 8192。这可能会导致缓冲区溢出。

关于c++ - RegKeyValue 返回无意义的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14430256/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com