try: lRes = RegCreateKeyEx(HKEY_CURRENT_USER, "mykey", 0, NULL, 0, KEY_READ | KEY_WRITE, NULL, &hkSub, &dwDisposition); Since you don^t fill the security attributes struct, passing a NULL pointer should do what you want. Same with classname..... Greetings, Davy