The function documentation says "If the buffer specified by lpData parameter is not large enough to hold the data, the function returns ERROR_MORE_DATA and stores the required buffer size in the variable pointed to by lpcbData. In this case, the contents of the lpData buffer are undefined."
The posted code calls RegQueryValueEx and tells the function that the size of the output buffer is 100 bytes even though the buffer size is actually 200 bytes. So understating the size of the buffer will cause RegQueryValueEx to fail if the data stored in the registry requires a buffer greater than 100 bytes. Initialize dwBytes to the actual size of the buffer.
Any progress, updates? Has your problem been solved?