+ if (hMachine == NULL)
+ {
+ hRootKey = HKEY_LOCAL_MACHINE;
+ }
+ else
+ {
+ if (RegConnectRegistryW(((PMACHINE_INFO)hMachine)->szMachineName,
+ HKEY_LOCAL_MACHINE,
+ &hRootKey))
+ {
+ ret = CR_REGISTRY_ERROR;
+ goto done;
+ }
+ }
+
+ if (Disposition == RegDisposition_OpenAlways)
+ {
+ lError = RegCreateKeyExW(hRootKey,
+ pszKeyPath,
+ 0,
+ NULL,
+ 0,
+ samDesired,
+ NULL,
+ phkDevice,
+ &dwDisposition);
+ }
+ else
+ {
+ lError = RegOpenKeyExW(hRootKey,
+ pszKeyPath,
+ 0,
+ samDesired,
+ phkDevice);
+ }