First: run RegQueryValueEx
to get type and necessary memory size:
Single byte code:
1 DWORD type, size; 2 vectortarget; 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 vectortarget; 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 }