Add stubs for InstallNewDevice, InstallSelectedDriver, UpdateDriverForPlugAndPlayDevi...
[reactos.git] / reactos / lib / newdev / newdev.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS New devices installation
4 * FILE: lib/newdev/newdev.c
5 * PURPOSE: New devices installation
6 *
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8 */
9
10 #include "newdev.h"
11
12 BOOL WINAPI
13 DevInstallW(
14 IN HWND Hwnd,
15 IN HINSTANCE Handle,
16 IN LPCWSTR InstanceId,
17 IN INT Show)
18 {
19 HDEVINFO hDevInfo;
20 SP_DEVINFO_DATA devInfoData;
21 SP_DRVINFO_DATA_W drvInfoData;
22 DWORD index;
23 BOOL ret;
24
25 DPRINT1("Installing device %S\n", InstanceId);
26
27 hDevInfo = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL);
28 if (hDevInfo == INVALID_HANDLE_VALUE)
29 {
30 DPRINT1("SetupDiCreateDeviceInfoListExW() failed with error 0x%lx\n", GetLastError());
31 return FALSE;
32 }
33
34 devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
35 ret = SetupDiOpenDeviceInfoW(
36 hDevInfo,
37 InstanceId,
38 NULL,
39 0, /* Open flags */
40 &devInfoData);
41 if (!ret)
42 {
43 DPRINT1("SetupDiOpenDeviceInfoW() failed with error 0x%lx\n", GetLastError());
44 return FALSE;
45 }
46
47 ret = SetupDiBuildDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER);
48 if (!ret)
49 {
50 DPRINT1("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
51 return FALSE;
52 }
53
54 #ifndef NDEBUG
55 ret = TRUE;
56 index = 0;
57 drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W);
58 while (ret)
59 {
60 ret = SetupDiEnumDriverInfoW(
61 hDevInfo,
62 &devInfoData,
63 SPDIT_COMPATDRIVER,
64 index,
65 &drvInfoData);
66 if (!ret)
67 {
68 if (GetLastError() != ERROR_NO_MORE_ITEMS)
69 {
70 DPRINT1("SetupDiEnumDriverInfoW() failed with error 0x%lx\n", GetLastError());
71 return FALSE;
72 }
73 break;
74 }
75 index++;
76 DPRINT1("- %S: %S\n", drvInfoData.MfgName, drvInfoData.Description);
77 }
78 #endif
79
80 ret = SetupDiCallClassInstaller(
81 DIF_SELECTBESTCOMPATDRV,
82 hDevInfo,
83 &devInfoData);
84 if (!ret)
85 {
86 DPRINT1("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%lx\n", GetLastError());
87 return FALSE;
88 }
89
90 ret = SetupDiCallClassInstaller(
91 DIF_ALLOW_INSTALL,
92 hDevInfo,
93 &devInfoData);
94 if (!ret)
95 {
96 DPRINT1("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%lx\n", GetLastError());
97 return FALSE;
98 }
99
100 ret = SetupDiCallClassInstaller(
101 DIF_NEWDEVICEWIZARD_PREANALYZE,
102 hDevInfo,
103 &devInfoData);
104 if (!ret)
105 {
106 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%lx\n", GetLastError());
107 return FALSE;
108 }
109
110 ret = SetupDiCallClassInstaller(
111 DIF_NEWDEVICEWIZARD_POSTANALYZE,
112 hDevInfo,
113 &devInfoData);
114 if (!ret)
115 {
116 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%lx\n", GetLastError());
117 return FALSE;
118 }
119
120 ret = SetupDiCallClassInstaller(
121 DIF_INSTALLDEVICEFILES,
122 hDevInfo,
123 &devInfoData);
124 if (!ret)
125 {
126 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%lx\n", GetLastError());
127 return FALSE;
128 }
129
130 ret = SetupDiCallClassInstaller(
131 DIF_REGISTER_COINSTALLERS,
132 hDevInfo,
133 &devInfoData);
134 if (!ret)
135 {
136 DPRINT1("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%lx\n", GetLastError());
137 return FALSE;
138 }
139
140 ret = SetupDiCallClassInstaller(
141 DIF_INSTALLINTERFACES,
142 hDevInfo,
143 &devInfoData);
144 if (!ret)
145 {
146 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%lx\n", GetLastError());
147 return FALSE;
148 }
149
150 ret = SetupDiCallClassInstaller(
151 DIF_INSTALLDEVICE,
152 hDevInfo,
153 &devInfoData);
154 if (!ret)
155 {
156 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%lx\n", GetLastError());
157 return FALSE;
158 }
159
160 ret = SetupDiCallClassInstaller(
161 DIF_NEWDEVICEWIZARD_FINISHINSTALL,
162 hDevInfo,
163 &devInfoData);
164 if (!ret)
165 {
166 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%lx\n", GetLastError());
167 return FALSE;
168 }
169
170 ret = SetupDiCallClassInstaller(
171 DIF_DESTROYPRIVATEDATA,
172 hDevInfo,
173 &devInfoData);
174 if (!ret)
175 {
176 DPRINT1("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%lx\n", GetLastError());
177 return FALSE;
178 }
179
180 ret = SetupDiDestroyDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER);
181 if (!ret)
182 {
183 DPRINT1("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
184 return FALSE;
185 }
186
187 ret = SetupDiDestroyDeviceInfoList(hDevInfo);
188 if (!ret)
189 {
190 DPRINT1("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
191 return FALSE;
192 }
193
194 return TRUE;
195 }