博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++读取REG_MULTI_SZ类型注册表
阅读量:4685 次
发布时间:2019-06-09

本文共 1564 字,大约阅读时间需要 5 分钟。

First: run RegQueryValueEx to get type and necessary memory size:

Single byte code:

1 DWORD type, size; 2 vector
target; 3 if ( RegQueryValueExA( 4 your_key, // HKEY 5 TEXT("ValueName"), 6 NULL, 7 &type, 8 NULL, 9 &size ) != ERROR_SUCCESS )10 return;11 if ( type == REG_MULTI_SZ )12 {13 vector
temp(size);14 15 if ( RegQueryValueExA(16 your_key, // HKEY17 TEXT("ValueName"),18 NULL,19 NULL,20 reinterpret_cast
(&temp[0]),21 &size ) != ERROR_SUCCESS )22 return;23 24 size_t index = 0;25 size_t len = strlen( &temp[0] );26 while ( len > 0 )27 {28 target.push_back(&temp[index]);29 index += len + 1;30 len = strlen( &temp[index] );31 }32 }

 

Unicode:

1 DWORD type, size; 2 vector
target; 3 if ( RegQueryValueExW( 4 your_key, // HKEY 5 TEXT("ValueName"), 6 NULL, 7 &type, 8 NULL, 9 &size ) != ERROR_SUCCESS )10 return;11 if ( type == REG_MULTI_SZ )12 {13 vector
temp(size/sizeof(wchar_t));14 15 if ( RegQueryValueExW(16 your_key, // HKEY17 TEXT("ValueName"),18 NULL,19 NULL,20 reinterpret_cast
(&temp[0]),21 &size ) != ERROR_SUCCESS )22 return;23 24 size_t index = 0;25 size_t len = wcslen( &temp[0] );26 while ( len > 0 )27 {28 target.push_back(&temp[index]);29 index += len + 1;30 len = wcslen( &temp[index] );31 }32 }

 

转载于:https://www.cnblogs.com/davygeek/p/5286193.html

你可能感兴趣的文章
项目范围管理(3):如何范围变更与过程控制?
查看>>
Mesos 配置项解析
查看>>
Jquery使用小结
查看>>
Java动态代理
查看>>
堆和栈的差别(转过无数次的文章)
查看>>
STL之Map的运用
查看>>
Linux常用命令
查看>>
JAVA多线程Thread VS Runnable详解
查看>>
springboot分布式数据源(Mysql)
查看>>
python安装numpy模块
查看>>
Lambda
查看>>
Java对byte数组压缩 解压缩 (zip,gzip,bzip2,jzlib)
查看>>
UDP用户数据报协议
查看>>
无聊到什么都不想做,只想写篇博客...
查看>>
Node实现websocket聊天室
查看>>
一天搞定CSS: 浮动(float)及文档流--10
查看>>
MSSQL游标和Fetch
查看>>
FFT最新卡常研究
查看>>
linux字符集的查看及修改
查看>>
php函数serialize()与unserialize()
查看>>