https://git.reactos.org/?p=reactos.git;a=commitdiff;h=90b3a9c09b748a4a63da1a7f3b9a78eb21743571

commit 90b3a9c09b748a4a63da1a7f3b9a78eb21743571
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Sat May 15 19:38:19 2021 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sat May 15 19:41:16 2021 +0200

    [MORE] Add code to load the current 'command extensions' enable status from 
the registry.
---
 base/applications/cmdutils/more/more.c | 53 ++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/base/applications/cmdutils/more/more.c 
b/base/applications/cmdutils/more/more.c
index 14dd0d54c32..b45ce967731 100644
--- a/base/applications/cmdutils/more/more.c
+++ b/base/applications/cmdutils/more/more.c
@@ -23,10 +23,12 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <windef.h>
 #include <winbase.h>
 #include <winnls.h>
+#include <winreg.h>
 #include <winuser.h>
 
 #include <conutils.h>
@@ -46,6 +48,9 @@ HANDLE hFile = INVALID_HANDLE_VALUE;
 HANDLE hStdIn, hStdOut;
 HANDLE hKeyboard;
 
+/* Enable/Disable extensions */
+BOOL bEnableExtensions = TRUE; // FIXME: By default, it should be FALSE.
+
 
 static BOOL
 __stdcall
@@ -440,6 +445,47 @@ FileGetString(
     return TRUE;
 }
 
+
+static VOID
+LoadRegistrySettings(HKEY hKeyRoot)
+{
+    LONG lRet;
+    HKEY hKey;
+    DWORD dwType, len;
+    /*
+     * Buffer big enough to hold the string L"4294967295",
+     * corresponding to the literal 0xFFFFFFFF (MAXULONG) in decimal.
+     */
+    DWORD Buffer[6];
+
+    lRet = RegOpenKeyExW(hKeyRoot,
+                         L"Software\\Microsoft\\Command Processor",
+                         0,
+                         KEY_QUERY_VALUE,
+                         &hKey);
+    if (lRet != ERROR_SUCCESS)
+        return;
+
+    len = sizeof(Buffer);
+    lRet = RegQueryValueExW(hKey,
+                            L"EnableExtensions",
+                            NULL,
+                            &dwType,
+                            (LPBYTE)&Buffer,
+                            &len);
+    if (lRet == ERROR_SUCCESS)
+    {
+        /* Overwrite the default setting */
+        if (dwType == REG_DWORD)
+            bEnableExtensions = !!*(PDWORD)Buffer;
+        else if (dwType == REG_SZ)
+            bEnableExtensions = (_wtol((PWSTR)Buffer) == 1);
+    }
+    // else, use the default setting set globally.
+
+    RegCloseKey(hKey);
+}
+
 // INT CommandMore(LPTSTR cmd, LPTSTR param)
 int wmain(int argc, WCHAR* argv[])
 {
@@ -480,6 +526,13 @@ int wmain(int argc, WCHAR* argv[])
         return 0;
     }
 
+    /* Load the registry settings */
+    LoadRegistrySettings(HKEY_LOCAL_MACHINE);
+    LoadRegistrySettings(HKEY_CURRENT_USER);
+
+    // TODO: First, load the "MORE" environment variable and parse it,
+    // then parse the command-line parameters.
+
     // FIXME: Parse all the remaining parameters.
     // Then the file list can be found at the very end.
     // FIXME2: Use the PARSER api that can be found in EVENTCREATE.

Reply via email to