1 | /** @file
|
---|
2 | *
|
---|
3 | * delinvalid - remove "InvalidDisplay" key on NT4
|
---|
4 | *
|
---|
5 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
6 | *
|
---|
7 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
8 | * available from http://www.virtualbox.org. This file is free software;
|
---|
9 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | * General Public License (GPL) as published by the Free Software
|
---|
11 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | */
|
---|
15 |
|
---|
16 | /*
|
---|
17 | Purpose:
|
---|
18 |
|
---|
19 | Delete the "InvalidDisplay" key which causes the display
|
---|
20 | applet to be started on every boot. For some reason this key
|
---|
21 | isn't removed after setting the proper resolution and even not when
|
---|
22 | doing a driver reinstall. Removing it doesn't seem to do any harm.
|
---|
23 | The key is inserted by windows on first reboot after installing
|
---|
24 | the VBox video driver using the VirtualBox utility.
|
---|
25 | It's not inserted when using the Display applet for installation.
|
---|
26 | There seems to be a subtle problem with the VirtualBox util.
|
---|
27 | */
|
---|
28 |
|
---|
29 | //#define _UNICODE
|
---|
30 |
|
---|
31 | #include <windows.h>
|
---|
32 | #include <setupapi.h>
|
---|
33 | #include <regstr.h>
|
---|
34 | #include <DEVGUID.h>
|
---|
35 | #include <stdio.h>
|
---|
36 |
|
---|
37 | #include "tchar.h"
|
---|
38 | #include "string.h"
|
---|
39 |
|
---|
40 | /*******************************************************************************
|
---|
41 | * Defined Constants And Macros *
|
---|
42 | *******************************************************************************/
|
---|
43 |
|
---|
44 | /////////////////////////////////////////////////////////////////////////////
|
---|
45 |
|
---|
46 |
|
---|
47 | BOOL isNT4 (void)
|
---|
48 | {
|
---|
49 | OSVERSIONINFO OSversion;
|
---|
50 |
|
---|
51 | OSversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
---|
52 | ::GetVersionEx(&OSversion);
|
---|
53 |
|
---|
54 | switch (OSversion.dwPlatformId)
|
---|
55 | {
|
---|
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;
|
---|
65 | }
|
---|
66 | return FALSE;
|
---|
67 | }
|
---|
68 |
|
---|
69 | int main (int argc, char **argv)
|
---|
70 | {
|
---|
71 | int rc = 0;
|
---|
72 |
|
---|
73 | /* This program is only for installing drivers on NT4 */
|
---|
74 | if (!isNT4())
|
---|
75 | {
|
---|
76 | printf("This program only runs on NT4\n");
|
---|
77 | return -1;
|
---|
78 | }
|
---|
79 |
|
---|
80 | /* 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"));
|
---|
86 |
|
---|
87 | return rc;
|
---|
88 | }
|
---|