[PATCH 1/2] reg: Output the number of matches when querying the registry recursively

Hugh McMaster hugh.mcmaster at outlook.com
Mon May 2 07:06:23 CDT 2016


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/reg/reg.c  | 7 +++++++
 programs/reg/reg.h  | 1 +
 programs/reg/reg.rc | 1 +
 3 files changed, 9 insertions(+)

diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index c9903ac..df3b453 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -655,6 +655,8 @@ static WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name,
     return subkey_path;
 }
 
+static unsigned int num_values_found = 0;
+
 static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
 {
     LONG rc;
@@ -689,6 +691,7 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
         output_string(fmt, path);
         output_value(value_name, type, data, data_size);
         output_string(newlineW);
+        num_values_found++;
     }
 
     HeapFree(GetProcessHeap(), 0, data);
@@ -858,7 +861,11 @@ static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, BOOL
     }
 
     if (value_name || value_empty)
+    {
         ret = query_value(key, value_name, key_name, recurse);
+        if (recurse)
+            output_message(STRING_MATCHES_FOUND, num_values_found);
+    }
     else
         ret = query_all(key, key_name, recurse);
 
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
index dd1e43e..102284e 100644
--- a/programs/reg/reg.h
+++ b/programs/reg/reg.h
@@ -46,3 +46,4 @@
 #define STRING_INVALID_STRING   123
 #define STRING_VALUEALL_FAILED  124
 #define STRING_GENERAL_FAILURE  125
+#define STRING_MATCHES_FOUND    126
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
index b4888ea..23144a3 100644
--- a/programs/reg/reg.rc
+++ b/programs/reg/reg.rc
@@ -51,4 +51,5 @@ STRINGTABLE
     STRING_INVALID_STRING, "reg: The option [/d] must be followed by a valid string\n"
     STRING_VALUEALL_FAILED, "reg: Unable to delete all registry values in '%1'. An unexpected error occurred.\n"
     STRING_GENERAL_FAILURE, "reg: Unable to complete the specified operation. An unexpected error occurred.\n"
+    STRING_MATCHES_FOUND, "Search complete. Number of matches found: %1!d!\n"
 }
-- 
1.9.1




More information about the wine-patches mailing list