changeset 2512:160e12614310

RegOpenKeyExA
author Ritor1
date Thu, 02 Oct 2014 19:33:01 +0600
parents e3a619609dae
children 28afacb08f76
files Engine/Registry.cpp
diffstat 1 files changed, 22 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/Engine/Registry.cpp	Fri Sep 19 18:03:18 2014 +0600
+++ b/Engine/Registry.cpp	Thu Oct 02 19:33:01 2014 +0600
@@ -97,7 +97,7 @@
 //----- (00464BEF) --------------------------------------------------------
 void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue)
 {
-  LSTATUS (__stdcall *v4)(HKEY); // esi@1
+  //LSTATUS (__stdcall *v4)(HKEY); // esi@1
   LSTATUS result; // eax@7
   DWORD Type; // [sp+Ch] [bp-24h]@5
   LPCSTR lpValueName; // [sp+10h] [bp-20h]@1
@@ -116,40 +116,29 @@
   v13 = 0;
   hKey = 0;
   phkResult = 0;
-  v4 = RegCloseKey;
-  if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey)
-    || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition)
-    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition)
-    || RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) )
-  {
-    result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
-  }
-  else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
-  {
-    RegCloseKey(v14);
-    v14 = 0;
-    result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
-  }
-  else
+  result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
+  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )
   {
-    v4 = RegCloseKey;
-    RegCloseKey(v14);
-    v14 = 0;
-    RegCloseKey(v13);
-    v13 = 0;
-    RegCloseKey(phkResult);
-    phkResult = 0;
-    result = RegCloseKey(hKey);
-    hKey = 0;
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition))
+    {
+      if (!RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition))
+      {
+        if( !RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) )
+        {
+          if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
+            GetLastError();
+          RegCloseKey(v14);
+          v14 = NULL;
+        }
+        RegCloseKey(v13);
+        v13 = NULL;
+      }
+      RegCloseKey(phkResult);
+      phkResult = NULL;
+    }
+    RegCloseKey(hKey);
+    hKey = NULL;
   }
-  if ( v14 )
-    result = v4(v14);
-  if ( v13 )
-    result = v4(v13);
-  if ( hKey )
-    result = v4(hKey);
-  if ( phkResult )
-    result = v4(phkResult);
 }
 
 //----- (00464D32) --------------------------------------------------------