VirtualBox

Ignore:
Timestamp:
Aug 20, 2022 2:49:33 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153189
Message:

Add/NT/Inst: Cleaned up RegCleanup, switched it to RegDeleteKeyW, removing unnecessary includes and printf dependency. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/RegCleanup.cpp

    r93115 r96372  
    11/* $Id$ */
    22/** @file
    3  * delinvalid - remove "InvalidDisplay" key on NT4
     3 * RegCleanup - Remove "InvalidDisplay" and "NewDisplay" keys on NT4,
     4 *              run via HKLM/.../Windows/CurrentVersion/RunOnce.
     5 *
     6 * Delete the "InvalidDisplay" key which causes the display applet to be
     7 * started on every boot. For some reason this key isn't removed after
     8 * setting the proper resolution and even not when * doing a driver reinstall.
     9 * Removing it doesn't seem to do any harm.  The key is inserted by windows on
     10 * first reboot after installing the VBox video driver using the VirtualBox
     11 * utility. It's not inserted when using the Display applet for installation.
     12 * There seems to be a subtle problem with the VirtualBox util.
    413 */
    514
     
    1625 */
    1726
    18 /*
    19  Purpose:
    20 
    21  Delete the "InvalidDisplay" key which causes the display
    22  applet to be started on every boot. For some reason this key
    23  isn't removed after setting the proper resolution and even not when
    24  doing a driver reinstall. Removing it doesn't seem to do any harm.
    25  The key is inserted by windows on first reboot after installing
    26  the VBox video driver using the VirtualBox utility.
    27  It's not inserted when using the Display applet for installation.
    28  There seems to be a subtle problem with the VirtualBox util.
    29  */
    30 
    3127
    3228/*********************************************************************************************************************************
    3329*   Header Files                                                                                                                 *
    3430*********************************************************************************************************************************/
    35 //#define _UNICODE
    36 
    3731#include <iprt/win/windows.h>
    38 #include <iprt/win/setupapi.h>
    39 #include <regstr.h>
    40 #include <DEVGUID.h>
    41 #include <stdio.h>
    42 
    43 #include "tchar.h"
    44 #include "string.h"
    4532
    4633
    47 BOOL isNT4(void)
     34static BOOL isNT4(void)
    4835{
    4936    OSVERSIONINFO OSversion;
     
    5441    switch (OSversion.dwPlatformId)
    5542    {
    56     case VER_PLATFORM_WIN32s:
    57     case VER_PLATFORM_WIN32_WINDOWS:
    58         return FALSE;
    59     case VER_PLATFORM_WIN32_NT:
    60         if (OSversion.dwMajorVersion == 4)
    61             return TRUE;
    62         else return FALSE;
    63     default:
    64         break;
     43        case VER_PLATFORM_WIN32s:
     44        case VER_PLATFORM_WIN32_WINDOWS:
     45            return FALSE;
     46        case VER_PLATFORM_WIN32_NT:
     47            if (OSversion.dwMajorVersion == 4)
     48                return TRUE;
     49            return FALSE;
     50        default:
     51            break;
    6552    }
    6653    return FALSE;
    6754}
    6855
     56
    6957int main()
    7058{
    71     int rc = 0;
    72 
    7359    /* This program is only for installing drivers on NT4 */
    7460    if (!isNT4())
    7561    {
    76         printf("This program only runs on NT4\n");
    77         return -1;
     62        DWORD cbIgn;
     63        WriteFile(GetStdHandle(STD_ERROR_HANDLE), RT_STR_TUPLE("This program only runs on NT4\r\n"), &cbIgn, NULL);
     64        return 1;
    7865    }
    7966
    8067    /* Delete the "InvalidDisplay" key which causes the display
    81      applet to be started on every boot. For some reason this key
    82      isn't removed after setting the proper resolution and even not when
    83      doing a driverreinstall.  */
    84     RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\InvalidDisplay"));
    85     RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\NewDisplay"));
     68       applet to be started on every boot. For some reason this key
     69       isn't removed after setting the proper resolution and even not when
     70       doing a driverreinstall.  */
     71    RegDeleteKeyW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\InvalidDisplay");
     72    RegDeleteKeyW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\NewDisplay");
    8673
    87     return rc;
     74    return 0;
    8875}
    8976
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette