Linked Questions

Popular Questions

This is a part of my assignment. I know how to open/read registry keys and create values, but i have few questions. My code:

This is how i write new string value into registry:

void lCreateKeyOne(HKEY hKey, LPCWSTR lSubKey)
WCHAR wcValue[] = TEXT"testvalue";
LONG lNewValue = RegSetValueEx (hKey, 

It works, but i want to generate random string and write it into registry key. This is how i generate random string:

static const char alphanum[] =

int stringLength = sizeof(alphanum) - 1;

char genRandom()
return alphanum[rand() % stringLength];
string Str;
for (unsigned int i = 0; i < 20; ++i)
   Str += genRandom();
  1. How to write it as registry key ?
  2. how to convert string Str to WCHAR wcValue[] ?
  3. I tried to use char instead of wchar and it writes chinese characters

Related Questions