1 | /* $Id: RegCleanup.cpp 96389 2022-08-20 23:09:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
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.
|
---|
13 | */
|
---|
14 |
|
---|
15 | /*
|
---|
16 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
17 | *
|
---|
18 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
19 | * available from http://www.virtualbox.org. This file is free software;
|
---|
20 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
21 | * General Public License (GPL) as published by the Free Software
|
---|
22 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
23 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
24 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include <iprt/win/windows.h>
|
---|
32 | #include <iprt/cdefs.h> /* RT_STR_TUPLE */
|
---|
33 | #include <iprt/types.h> /* RTEXITCODE_FAILURE */
|
---|
34 |
|
---|
35 |
|
---|
36 | static bool IsNt4(void)
|
---|
37 | {
|
---|
38 | OSVERSIONINFOW VerInfo = { sizeof(VerInfo), 0 };
|
---|
39 | GetVersionExW(&VerInfo);
|
---|
40 | return VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT
|
---|
41 | && VerInfo.dwMajorVersion == 4;
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | int main()
|
---|
46 | {
|
---|
47 | if (!IsNt4())
|
---|
48 | {
|
---|
49 | DWORD cbIgn;
|
---|
50 | WriteFile(GetStdHandle(STD_ERROR_HANDLE), RT_STR_TUPLE("This program only runs on NT4\r\n"), &cbIgn, NULL);
|
---|
51 | return RTEXITCODE_FAILURE;
|
---|
52 | }
|
---|
53 |
|
---|
54 | /* Delete the "InvalidDisplay" key which causes the display
|
---|
55 | applet to be started on every boot. For some reason this key
|
---|
56 | isn't removed after setting the proper resolution and even not when
|
---|
57 | doing a driverreinstall. */
|
---|
58 | RegDeleteKeyW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\InvalidDisplay");
|
---|
59 | RegDeleteKeyW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\GraphicsDrivers\\NewDisplay");
|
---|
60 | return RTEXITCODE_SUCCESS;
|
---|
61 | }
|
---|
62 |
|
---|