gpt4 book ai didi

c++ - 如何将 REG_MULTI_SZ 值写入注册表?

转载 作者:太空宇宙 更新时间:2023-11-04 16:30:40 25 4
gpt4 key购买 nike

我正在尝试使用 C++ 将 REG_MULTI_SZ 值写入 Windows 注册表。我卡住的地方是将我必须的 c 字符串转换为 MULTI_SZ 格式。有没有方便的方法来做到这一点?

最佳答案

你必须自己做。给定

char ** strings; // array of strings
int N; // number of strings

你数一下multi_sz的长度

int len=1;
for(int i=0; i<N; i++)
len += strlen(strings[i])+1;

并填写

char* multi_sz = malloc(len), ptr=multi_sz;
memset(multi_sz, 0, len);
for(int i=0; i<N; i++) {
strcpy(ptr, strings[i]);
ptr += strlen(strings[i])+1;
}

关于c++ - 如何将 REG_MULTI_SZ 值写入注册表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7421601/

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