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
7 * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
16 IN LPCWSTR InstanceId
,
20 SP_DEVINFO_DATA devInfoData
;
21 SP_DRVINFO_DATA_W drvInfoData
;
25 DPRINT1("Installing device %S\n", InstanceId
);
27 hDevInfo
= SetupDiCreateDeviceInfoListExW(NULL
, NULL
, NULL
, NULL
);
28 if (hDevInfo
== INVALID_HANDLE_VALUE
)
30 DPRINT1("SetupDiCreateDeviceInfoListExW() failed with error 0x%lx\n", GetLastError());
34 devInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
35 ret
= SetupDiOpenDeviceInfoW(
43 DPRINT1("SetupDiOpenDeviceInfoW() failed with error 0x%lx\n", GetLastError());
47 ret
= SetupDiBuildDriverInfoList(hDevInfo
, &devInfoData
, SPDIT_COMPATDRIVER
);
50 DPRINT1("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
57 drvInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA_W
);
60 ret
= SetupDiEnumDriverInfoW(
68 if (GetLastError() != ERROR_NO_MORE_ITEMS
)
70 DPRINT1("SetupDiEnumDriverInfoW() failed with error 0x%lx\n", GetLastError());
76 DPRINT1("- %S: %S\n", drvInfoData
.MfgName
, drvInfoData
.Description
);
80 ret
= SetupDiCallClassInstaller(
81 DIF_SELECTBESTCOMPATDRV
,
86 DPRINT1("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%lx\n", GetLastError());
90 ret
= SetupDiCallClassInstaller(
96 DPRINT1("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%lx\n", GetLastError());
100 ret
= SetupDiCallClassInstaller(
101 DIF_NEWDEVICEWIZARD_PREANALYZE
,
106 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%lx\n", GetLastError());
110 ret
= SetupDiCallClassInstaller(
111 DIF_NEWDEVICEWIZARD_POSTANALYZE
,
116 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%lx\n", GetLastError());
120 ret
= SetupDiCallClassInstaller(
121 DIF_INSTALLDEVICEFILES
,
126 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%lx\n", GetLastError());
130 ret
= SetupDiCallClassInstaller(
131 DIF_REGISTER_COINSTALLERS
,
136 DPRINT1("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%lx\n", GetLastError());
140 ret
= SetupDiCallClassInstaller(
141 DIF_INSTALLINTERFACES
,
146 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%lx\n", GetLastError());
150 ret
= SetupDiCallClassInstaller(
156 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%lx\n", GetLastError());
160 ret
= SetupDiCallClassInstaller(
161 DIF_NEWDEVICEWIZARD_FINISHINSTALL
,
166 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%lx\n", GetLastError());
170 ret
= SetupDiCallClassInstaller(
171 DIF_DESTROYPRIVATEDATA
,
176 DPRINT1("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%lx\n", GetLastError());
180 ret
= SetupDiDestroyDriverInfoList(hDevInfo
, &devInfoData
, SPDIT_COMPATDRIVER
);
183 DPRINT1("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
187 ret
= SetupDiDestroyDeviceInfoList(hDevInfo
);
190 DPRINT1("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());