commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r815202 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c
Date Tue, 15 Sep 2009 08:05:38 GMT
Author: mturk
Date: Tue Sep 15 08:05:37 2009
New Revision: 815202

URL: http://svn.apache.org/viewvc?rev=815202&view=rev
Log:
Implement API for checking the existance of a key/value

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c?rev=815202&r1=815201&r2=815202&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/registry.c Tue Sep 15 08:05:37
2009
@@ -366,3 +366,35 @@
     x_free(wn);
     return rc;
 }
+
+ACR_DECLARE(int) RegistryHasA(const char *name)
+{
+    int   i;
+    HKEY  r;
+    char *p;
+    x_registry_t k;
+    wchar_t *s = NULL;
+
+    if (!(r = reg_rootnamed(name))) {
+        return ACR_EINVAL;
+    }
+
+    if (!(p = strchr(name, '\\'))) {
+        return ACR_EINVAL;
+    }
+    k.name = x_wcsdup_utf8(p + 1);
+    k.sam  = KEY_READ;
+    k.key  = 0;
+    if ((s = wcsrchr(k.name, L'\\'))) {
+        *(s++) = L'\0';
+    }
+    else {
+        x_free(k.name);
+        return ACR_EINVAL;
+    }
+    i = RegOpenKeyExW(r, k.name, 0, k.sam, &k.key);
+
+    SAFE_CLOSE_KEY(k.key);
+    x_free(k.name);
+    return i;
+}



Mime
View raw message