2 * ReactOS New devices installation
3 * Copyright (C) 2004 ReactOS Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * PROJECT: ReactOS New devices installation
21 * FILE: lib/newdev/newdev.c
22 * PURPOSE: New devices installation
23 * PROGRAMMER: Hervé Poussineau (hpoussin@reactos.org)
29 ULONG
DbgPrint(PCH Format
,...);
30 #define UNIMPLEMENTED \
31 DbgPrint("NEWDEV: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__)
32 #define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
38 IN LPCWSTR InstanceId
,
42 SP_DEVINFO_DATA devInfoData
;
43 SP_DRVINFO_DATA_W drvInfoData
;
48 DbgPrint("Installing device %S\n", InstanceId
);
50 hDevInfo
= SetupDiCreateDeviceInfoListExW(NULL
, NULL
, NULL
, NULL
);
51 if (hDevInfo
== INVALID_HANDLE_VALUE
)
53 DPRINT1("SetupDiCreateDeviceInfoListExW() failed with error 0x%lx\n", GetLastError());
57 devInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
58 ret
= SetupDiOpenDeviceInfoW(
66 DPRINT1("SetupDiOpenDeviceInfoW() failed with error 0x%lx\n", GetLastError());
70 ret
= SetupDiBuildDriverInfoList(hDevInfo
, &devInfoData
, SPDIT_COMPATDRIVER
);
73 DPRINT1("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
80 drvInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA_W
);
83 ret
= SetupDiEnumDriverInfoW(
91 if (GetLastError() != ERROR_NO_MORE_ITEMS
)
93 DPRINT1("SetupDiEnumDriverInfoW() failed with error 0x%lx\n", GetLastError());
99 DPRINT1("- %S: %S\n", drvInfoData
.MfgName
, drvInfoData
.Description
);
103 ret
= SetupDiCallClassInstaller(
104 DIF_SELECTBESTCOMPATDRV
,
109 DPRINT1("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%lx\n", GetLastError());
113 ret
= SetupDiCallClassInstaller(
119 DPRINT1("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%lx\n", GetLastError());
123 ret
= SetupDiCallClassInstaller(
124 DIF_NEWDEVICEWIZARD_PREANALYZE
,
129 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%lx\n", GetLastError());
133 ret
= SetupDiCallClassInstaller(
134 DIF_NEWDEVICEWIZARD_POSTANALYZE
,
139 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%lx\n", GetLastError());
143 ret
= SetupDiCallClassInstaller(
144 DIF_INSTALLDEVICEFILES
,
149 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%lx\n", GetLastError());
153 ret
= SetupDiCallClassInstaller(
154 DIF_REGISTER_COINSTALLERS
,
159 DPRINT1("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%lx\n", GetLastError());
163 ret
= SetupDiCallClassInstaller(
164 DIF_INSTALLINTERFACES
,
169 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%lx\n", GetLastError());
173 ret
= SetupDiCallClassInstaller(
179 DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%lx\n", GetLastError());
183 ret
= SetupDiCallClassInstaller(
184 DIF_NEWDEVICEWIZARD_FINISHINSTALL
,
189 DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%lx\n", GetLastError());
193 ret
= SetupDiCallClassInstaller(
194 DIF_DESTROYPRIVATEDATA
,
199 DPRINT1("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%lx\n", GetLastError());
203 ret
= SetupDiDestroyDriverInfoList(hDevInfo
, &devInfoData
, SPDIT_COMPATDRIVER
);
206 DPRINT1("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
210 ret
= SetupDiDestroyDeviceInfoList(hDevInfo
);
213 DPRINT1("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());