gdi32: Use NtGdiPolyPolyDraw for PolylineTo implementation.
[wine.git] / dlls / newdev / main.c
blob72e7cbc690d76b21b9db9af56297977c58168c73
1 /*
2 * New Device installation API
4 * Copyright 2003 Ulrich Czekalla
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winerror.h"
25 #include "winbase.h"
26 #include "winnls.h"
27 #include "winuser.h"
28 #include "winreg.h"
29 #include "cfgmgr32.h"
30 #include "newdev.h"
32 #include "wine/debug.h"
33 #include "wine/heap.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
37 /***********************************************************************
38 * InstallNewDevice (NEWDEV.@)
40 BOOL WINAPI InstallNewDevice(HWND hwndParent, LPGUID ClassGuid, PDWORD pReboot)
42 FIXME("Stub!\n");
43 return TRUE;
46 /***********************************************************************
47 * InstallSelectedDriver (NEWDEV.@)
49 BOOL WINAPI InstallSelectedDriver(HWND parent, HDEVINFO info, const WCHAR *reserved, BOOL backup, DWORD *reboot)
51 FIXME("Stub! %p %p %s %u %p\n", parent, info, debugstr_w(reserved), backup, reboot);
52 return TRUE;
55 /***********************************************************************
56 * UpdateDriverForPlugAndPlayDevicesA (NEWDEV.@)
58 BOOL WINAPI UpdateDriverForPlugAndPlayDevicesA(HWND parent, const char *hardware_id,
59 const char *inf_path, DWORD flags, BOOL *reboot)
61 WCHAR hardware_idW[MAX_DEVICE_ID_LEN];
62 WCHAR inf_pathW[MAX_PATH];
64 MultiByteToWideChar(CP_ACP, 0, hardware_id, -1, hardware_idW, ARRAY_SIZE(hardware_idW));
65 MultiByteToWideChar(CP_ACP, 0, inf_path, -1, inf_pathW, ARRAY_SIZE(inf_pathW));
67 return UpdateDriverForPlugAndPlayDevicesW(parent, hardware_idW, inf_pathW, flags, reboot);
70 static BOOL hardware_id_matches(const WCHAR *id, const WCHAR *device_ids)
72 while (*device_ids)
74 if (!wcscmp(id, device_ids))
75 return TRUE;
76 device_ids += lstrlenW(device_ids) + 1;
78 return FALSE;
81 /***********************************************************************
82 * UpdateDriverForPlugAndPlayDevicesW (NEWDEV.@)
84 BOOL WINAPI UpdateDriverForPlugAndPlayDevicesW(HWND parent, const WCHAR *hardware_id,
85 const WCHAR *inf_path, DWORD flags, BOOL *reboot)
87 SP_DEVINSTALL_PARAMS_W params = {sizeof(params)};
88 SP_DEVINFO_DATA device = {sizeof(device)};
89 WCHAR *device_ids = NULL;
90 DWORD size = 0, i, j;
91 HDEVINFO set;
93 static const DWORD dif_list[] =
95 DIF_SELECTBESTCOMPATDRV,
96 DIF_ALLOW_INSTALL,
97 DIF_INSTALLDEVICEFILES,
98 DIF_REGISTER_COINSTALLERS,
99 DIF_INSTALLINTERFACES,
100 DIF_INSTALLDEVICE,
101 DIF_NEWDEVICEWIZARD_FINISHINSTALL,
104 TRACE("parent %p, hardware_id %s, inf_path %s, flags %#x, reboot %p.\n",
105 parent, debugstr_w(hardware_id), debugstr_w(inf_path), flags, reboot);
107 if (flags)
108 FIXME("Unhandled flags %#x.\n", flags);
110 if (reboot) *reboot = FALSE;
112 if ((set = SetupDiGetClassDevsW(NULL, NULL, 0, DIGCF_ALLCLASSES)) == INVALID_HANDLE_VALUE)
113 return FALSE;
115 for (i = 0; SetupDiEnumDeviceInfo(set, i, &device); ++i)
117 if (!SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_HARDWAREID, NULL, (BYTE *)device_ids, size, &size))
119 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
120 continue;
121 device_ids = heap_realloc(device_ids, size);
122 SetupDiGetDeviceRegistryPropertyW(set, &device, SPDRP_HARDWAREID, NULL, (BYTE *)device_ids, size, NULL);
125 if (!hardware_id_matches(hardware_id, device_ids))
126 continue;
128 if (!SetupDiGetDeviceInstallParamsW(set, &device, &params))
129 continue;
131 lstrcpyW(params.DriverPath, inf_path);
132 params.Flags |= DI_ENUMSINGLEINF;
133 if (!SetupDiSetDeviceInstallParamsW(set, &device, &params))
134 continue;
136 if (!SetupDiBuildDriverInfoList(set, &device, SPDIT_COMPATDRIVER))
137 continue;
139 for (j = 0; j < ARRAY_SIZE(dif_list); ++j)
141 if (!SetupDiCallClassInstaller(dif_list[j], set, &device) && GetLastError() != ERROR_DI_DO_DEFAULT)
142 break;
146 SetupDiDestroyDeviceInfoList(set);
147 heap_free(device_ids);
148 return TRUE;
152 /***********************************************************************
153 * DiInstallDriverA (NEWDEV.@)
155 BOOL WINAPI DiInstallDriverA(HWND parent, const char *inf_path, DWORD flags, BOOL *reboot)
157 FIXME("parent %p, inf_path %s, flags %#x, reboot %p, stub!\n", parent, debugstr_a(inf_path), flags, reboot);
158 return TRUE;
161 /***********************************************************************
162 * DiInstallDriverW (NEWDEV.@)
164 BOOL WINAPI DiInstallDriverW(HWND parent, const WCHAR *inf_path, DWORD flags, BOOL *reboot)
166 FIXME("parent %p, inf_path %s, flags %#x, reboot %p, stub!\n", parent, debugstr_w(inf_path), flags, reboot);
167 return TRUE;