diff --git a/reactos/dll/win32/newdev/newdev.c b/reactos/dll/win32/newdev/newdev.c index e371736c503..de65a97dd44 100644 --- a/reactos/dll/win32/newdev/newdev.c +++ b/reactos/dll/win32/newdev/newdev.c @@ -29,174 +29,174 @@ HINSTANCE hDllInstance; static BOOL SearchDriver( - IN PDEVINSTDATA DevInstData, - IN LPCWSTR Directory OPTIONAL, - IN LPCWSTR InfFile OPTIONAL); + IN PDEVINSTDATA DevInstData, + IN LPCWSTR Directory OPTIONAL, + IN LPCWSTR InfFile OPTIONAL); /* * @implemented */ BOOL WINAPI UpdateDriverForPlugAndPlayDevicesW( - IN HWND hwndParent, - IN LPCWSTR HardwareId, - IN LPCWSTR FullInfPath, - IN DWORD InstallFlags, - OUT PBOOL bRebootRequired OPTIONAL) + IN HWND hwndParent, + IN LPCWSTR HardwareId, + IN LPCWSTR FullInfPath, + IN DWORD InstallFlags, + OUT PBOOL bRebootRequired OPTIONAL) { - DEVINSTDATA DevInstData; - DWORD i; - LPWSTR Buffer = NULL; - DWORD BufferSize; - LPCWSTR CurrentHardwareId; /* Pointer into Buffer */ - BOOL FoundHardwareId, FoundAtLeastOneDevice = FALSE; - BOOL ret = FALSE; + DEVINSTDATA DevInstData; + DWORD i; + LPWSTR Buffer = NULL; + DWORD BufferSize; + LPCWSTR CurrentHardwareId; /* Pointer into Buffer */ + BOOL FoundHardwareId, FoundAtLeastOneDevice = FALSE; + BOOL ret = FALSE; - DevInstData.hDevInfo = INVALID_HANDLE_VALUE; + DevInstData.hDevInfo = INVALID_HANDLE_VALUE; - TRACE("UpdateDriverForPlugAndPlayDevicesW(%p %s %s 0x%x %p)\n", - hwndParent, debugstr_w(HardwareId), debugstr_w(FullInfPath), InstallFlags, bRebootRequired); + TRACE("UpdateDriverForPlugAndPlayDevicesW(%p %s %s 0x%x %p)\n", + hwndParent, debugstr_w(HardwareId), debugstr_w(FullInfPath), InstallFlags, bRebootRequired); - /* FIXME: InstallFlags bRebootRequired ignored! */ + /* FIXME: InstallFlags bRebootRequired ignored! */ - /* Check flags */ - if (InstallFlags & ~(INSTALLFLAG_FORCE | INSTALLFLAG_READONLY | INSTALLFLAG_NONINTERACTIVE)) - { - TRACE("Unknown flags: 0x%08lx\n", InstallFlags & ~(INSTALLFLAG_FORCE | INSTALLFLAG_READONLY | INSTALLFLAG_NONINTERACTIVE)); - SetLastError(ERROR_INVALID_FLAGS); - goto cleanup; - } + /* Check flags */ + if (InstallFlags & ~(INSTALLFLAG_FORCE | INSTALLFLAG_READONLY | INSTALLFLAG_NONINTERACTIVE)) + { + TRACE("Unknown flags: 0x%08lx\n", InstallFlags & ~(INSTALLFLAG_FORCE | INSTALLFLAG_READONLY | INSTALLFLAG_NONINTERACTIVE)); + SetLastError(ERROR_INVALID_FLAGS); + goto cleanup; + } - /* Enumerate all devices of the system */ - DevInstData.hDevInfo = SetupDiGetClassDevsW(NULL, NULL, hwndParent, DIGCF_ALLCLASSES | DIGCF_PRESENT); - if (DevInstData.hDevInfo == INVALID_HANDLE_VALUE) - goto cleanup; - DevInstData.devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - for (i = 0; ; i++) - { - if (!SetupDiEnumDeviceInfo(DevInstData.hDevInfo, i, &DevInstData.devInfoData)) - { - if (GetLastError() != ERROR_NO_MORE_ITEMS) - { - TRACE("SetupDiEnumDeviceInfo() failed with error 0x%x\n", GetLastError()); - goto cleanup; - } - /* This error was expected */ - break; - } + /* Enumerate all devices of the system */ + DevInstData.hDevInfo = SetupDiGetClassDevsW(NULL, NULL, hwndParent, DIGCF_ALLCLASSES | DIGCF_PRESENT); + if (DevInstData.hDevInfo == INVALID_HANDLE_VALUE) + goto cleanup; + DevInstData.devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + for (i = 0; ; i++) + { + if (!SetupDiEnumDeviceInfo(DevInstData.hDevInfo, i, &DevInstData.devInfoData)) + { + if (GetLastError() != ERROR_NO_MORE_ITEMS) + { + TRACE("SetupDiEnumDeviceInfo() failed with error 0x%x\n", GetLastError()); + goto cleanup; + } + /* This error was expected */ + break; + } - /* Get Hardware ID */ - HeapFree(GetProcessHeap(), 0, Buffer); - Buffer = NULL; - BufferSize = 0; - while (!SetupDiGetDeviceRegistryPropertyW( - DevInstData.hDevInfo, - &DevInstData.devInfoData, - SPDRP_HARDWAREID, - NULL, - (PBYTE)Buffer, - BufferSize, - &BufferSize)) - { - if (GetLastError() == ERROR_FILE_NOT_FOUND) - { - Buffer = NULL; - break; - } - else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - TRACE("SetupDiGetDeviceRegistryPropertyW() failed with error 0x%x\n", GetLastError()); - goto cleanup; - } - /* This error was expected */ - HeapFree(GetProcessHeap(), 0, Buffer); - Buffer = HeapAlloc(GetProcessHeap(), 0, BufferSize); - if (!Buffer) - { - TRACE("HeapAlloc() failed\n", GetLastError()); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - goto cleanup; - } - } - if (Buffer == NULL) - continue; + /* Get Hardware ID */ + HeapFree(GetProcessHeap(), 0, Buffer); + Buffer = NULL; + BufferSize = 0; + while (!SetupDiGetDeviceRegistryPropertyW( + DevInstData.hDevInfo, + &DevInstData.devInfoData, + SPDRP_HARDWAREID, + NULL, + (PBYTE)Buffer, + BufferSize, + &BufferSize)) + { + if (GetLastError() == ERROR_FILE_NOT_FOUND) + { + Buffer = NULL; + break; + } + else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + { + TRACE("SetupDiGetDeviceRegistryPropertyW() failed with error 0x%x\n", GetLastError()); + goto cleanup; + } + /* This error was expected */ + HeapFree(GetProcessHeap(), 0, Buffer); + Buffer = HeapAlloc(GetProcessHeap(), 0, BufferSize); + if (!Buffer) + { + TRACE("HeapAlloc() failed\n", GetLastError()); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + goto cleanup; + } + } + if (Buffer == NULL) + continue; - /* Check if we match the given hardware ID */ - FoundHardwareId = FALSE; - for (CurrentHardwareId = Buffer; *CurrentHardwareId != UNICODE_NULL; CurrentHardwareId += wcslen(CurrentHardwareId) + 1) - { - if (wcscmp(CurrentHardwareId, HardwareId) == 0) - { - FoundHardwareId = TRUE; - break; - } - } - if (!FoundHardwareId) - continue; + /* Check if we match the given hardware ID */ + FoundHardwareId = FALSE; + for (CurrentHardwareId = Buffer; *CurrentHardwareId != UNICODE_NULL; CurrentHardwareId += wcslen(CurrentHardwareId) + 1) + { + if (wcscmp(CurrentHardwareId, HardwareId) == 0) + { + FoundHardwareId = TRUE; + break; + } + } + if (!FoundHardwareId) + continue; - /* We need to try to update the driver of this device */ + /* We need to try to update the driver of this device */ - /* Get Instance ID */ - HeapFree(GetProcessHeap(), 0, Buffer); - Buffer = NULL; - if (SetupDiGetDeviceInstanceIdW(DevInstData.hDevInfo, &DevInstData.devInfoData, NULL, 0, &BufferSize)) - { - /* Error, as the output buffer should be too small */ - SetLastError(ERROR_GEN_FAILURE); - goto cleanup; - } - else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - TRACE("SetupDiGetDeviceInstanceIdW() failed with error 0x%x\n", GetLastError()); - goto cleanup; - } - else if ((Buffer = HeapAlloc(GetProcessHeap(), 0, BufferSize * sizeof(WCHAR))) == NULL) - { - TRACE("HeapAlloc() failed\n", GetLastError()); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - goto cleanup; - } - else if (!SetupDiGetDeviceInstanceIdW(DevInstData.hDevInfo, &DevInstData.devInfoData, Buffer, BufferSize, NULL)) - { - TRACE("SetupDiGetDeviceInstanceIdW() failed with error 0x%x\n", GetLastError()); - goto cleanup; - } - TRACE("Trying to update the driver of %s\n", debugstr_w(Buffer)); + /* Get Instance ID */ + HeapFree(GetProcessHeap(), 0, Buffer); + Buffer = NULL; + if (SetupDiGetDeviceInstanceIdW(DevInstData.hDevInfo, &DevInstData.devInfoData, NULL, 0, &BufferSize)) + { + /* Error, as the output buffer should be too small */ + SetLastError(ERROR_GEN_FAILURE); + goto cleanup; + } + else if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + { + TRACE("SetupDiGetDeviceInstanceIdW() failed with error 0x%x\n", GetLastError()); + goto cleanup; + } + else if ((Buffer = HeapAlloc(GetProcessHeap(), 0, BufferSize * sizeof(WCHAR))) == NULL) + { + TRACE("HeapAlloc() failed\n", GetLastError()); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + goto cleanup; + } + else if (!SetupDiGetDeviceInstanceIdW(DevInstData.hDevInfo, &DevInstData.devInfoData, Buffer, BufferSize, NULL)) + { + TRACE("SetupDiGetDeviceInstanceIdW() failed with error 0x%x\n", GetLastError()); + goto cleanup; + } + TRACE("Trying to update the driver of %s\n", debugstr_w(Buffer)); - /* Search driver in the specified .inf file */ - if (!SearchDriver(&DevInstData, NULL, FullInfPath)) - { - TRACE("SearchDriver() failed with error 0x%x\n", GetLastError()); - continue; - } + /* Search driver in the specified .inf file */ + if (!SearchDriver(&DevInstData, NULL, FullInfPath)) + { + TRACE("SearchDriver() failed with error 0x%x\n", GetLastError()); + continue; + } - /* FIXME: HACK! We shouldn't check of ERROR_PRIVILEGE_NOT_HELD */ - //if (!InstallCurrentDriver(&DevInstData)) - if (!InstallCurrentDriver(&DevInstData) && GetLastError() != ERROR_PRIVILEGE_NOT_HELD) - { - TRACE("InstallCurrentDriver() failed with error 0x%x\n", GetLastError()); - continue; - } + /* FIXME: HACK! We shouldn't check of ERROR_PRIVILEGE_NOT_HELD */ + //if (!InstallCurrentDriver(&DevInstData)) + if (!InstallCurrentDriver(&DevInstData) && GetLastError() != ERROR_PRIVILEGE_NOT_HELD) + { + TRACE("InstallCurrentDriver() failed with error 0x%x\n", GetLastError()); + continue; + } - FoundAtLeastOneDevice = TRUE; - } + FoundAtLeastOneDevice = TRUE; + } - if (FoundAtLeastOneDevice) - { - SetLastError(NO_ERROR); - ret = TRUE; - } - else - { - TRACE("No device found with HardwareID %s\n", debugstr_w(HardwareId)); - SetLastError(ERROR_NO_SUCH_DEVINST); - } + if (FoundAtLeastOneDevice) + { + SetLastError(NO_ERROR); + ret = TRUE; + } + else + { + TRACE("No device found with HardwareID %s\n", debugstr_w(HardwareId)); + SetLastError(ERROR_NO_SUCH_DEVINST); + } cleanup: - if (DevInstData.hDevInfo != INVALID_HANDLE_VALUE) - SetupDiDestroyDeviceInfoList(DevInstData.hDevInfo); - HeapFree(GetProcessHeap(), 0, Buffer); - return ret; + if (DevInstData.hDevInfo != INVALID_HANDLE_VALUE) + SetupDiDestroyDeviceInfoList(DevInstData.hDevInfo); + HeapFree(GetProcessHeap(), 0, Buffer); + return ret; } /* @@ -204,429 +204,429 @@ cleanup: */ BOOL WINAPI UpdateDriverForPlugAndPlayDevicesA( - IN HWND hwndParent, - IN LPCSTR HardwareId, - IN LPCSTR FullInfPath, - IN DWORD InstallFlags, - OUT PBOOL bRebootRequired OPTIONAL) + IN HWND hwndParent, + IN LPCSTR HardwareId, + IN LPCSTR FullInfPath, + IN DWORD InstallFlags, + OUT PBOOL bRebootRequired OPTIONAL) { - BOOL Result; - LPWSTR HardwareIdW = NULL; - LPWSTR FullInfPathW = NULL; + BOOL Result; + LPWSTR HardwareIdW = NULL; + LPWSTR FullInfPathW = NULL; - int len = MultiByteToWideChar(CP_ACP, 0, HardwareId, -1, NULL, 0); - HardwareIdW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!HardwareIdW) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - MultiByteToWideChar(CP_ACP, 0, HardwareId, -1, HardwareIdW, len); + int len = MultiByteToWideChar(CP_ACP, 0, HardwareId, -1, NULL, 0); + HardwareIdW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!HardwareIdW) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + MultiByteToWideChar(CP_ACP, 0, HardwareId, -1, HardwareIdW, len); - len = MultiByteToWideChar(CP_ACP, 0, FullInfPath, -1, NULL, 0); - FullInfPathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (!FullInfPathW) - { - HeapFree(GetProcessHeap(), 0, HardwareIdW); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - MultiByteToWideChar(CP_ACP, 0, FullInfPath, -1, FullInfPathW, len); + len = MultiByteToWideChar(CP_ACP, 0, FullInfPath, -1, NULL, 0); + FullInfPathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!FullInfPathW) + { + HeapFree(GetProcessHeap(), 0, HardwareIdW); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + MultiByteToWideChar(CP_ACP, 0, FullInfPath, -1, FullInfPathW, len); - Result = UpdateDriverForPlugAndPlayDevicesW( - hwndParent, - HardwareIdW, - FullInfPathW, - InstallFlags, - bRebootRequired); + Result = UpdateDriverForPlugAndPlayDevicesW( + hwndParent, + HardwareIdW, + FullInfPathW, + InstallFlags, + bRebootRequired); - HeapFree(GetProcessHeap(), 0, HardwareIdW); - HeapFree(GetProcessHeap(), 0, FullInfPathW); + HeapFree(GetProcessHeap(), 0, HardwareIdW); + HeapFree(GetProcessHeap(), 0, FullInfPathW); - return Result; + return Result; } /* Directory and InfFile MUST NOT be specified simultaneously */ static BOOL SearchDriver( - IN PDEVINSTDATA DevInstData, - IN LPCWSTR Directory OPTIONAL, - IN LPCWSTR InfFile OPTIONAL) + IN PDEVINSTDATA DevInstData, + IN LPCWSTR Directory OPTIONAL, + IN LPCWSTR InfFile OPTIONAL) { - SP_DEVINSTALL_PARAMS_W DevInstallParams = {0,}; - BOOL ret; + SP_DEVINSTALL_PARAMS_W DevInstallParams = {0,}; + BOOL ret; - DevInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W); - if (!SetupDiGetDeviceInstallParamsW(DevInstData->hDevInfo, &DevInstData->devInfoData, &DevInstallParams)) - { - TRACE("SetupDiGetDeviceInstallParams() failed with error 0x%x\n", GetLastError()); - return FALSE; - } - DevInstallParams.FlagsEx |= DI_FLAGSEX_ALLOWEXCLUDEDDRVS; + DevInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W); + if (!SetupDiGetDeviceInstallParamsW(DevInstData->hDevInfo, &DevInstData->devInfoData, &DevInstallParams)) + { + TRACE("SetupDiGetDeviceInstallParams() failed with error 0x%x\n", GetLastError()); + return FALSE; + } + DevInstallParams.FlagsEx |= DI_FLAGSEX_ALLOWEXCLUDEDDRVS; - if (InfFile) - { - DevInstallParams.Flags |= DI_ENUMSINGLEINF; - wcsncpy(DevInstallParams.DriverPath, InfFile, MAX_PATH); - } - else if (Directory) - { - DevInstallParams.Flags &= ~DI_ENUMSINGLEINF; - wcsncpy(DevInstallParams.DriverPath, Directory, MAX_PATH); - } - else - { - DevInstallParams.Flags &= ~DI_ENUMSINGLEINF; - *DevInstallParams.DriverPath = '\0'; - } + if (InfFile) + { + DevInstallParams.Flags |= DI_ENUMSINGLEINF; + wcsncpy(DevInstallParams.DriverPath, InfFile, MAX_PATH); + } + else if (Directory) + { + DevInstallParams.Flags &= ~DI_ENUMSINGLEINF; + wcsncpy(DevInstallParams.DriverPath, Directory, MAX_PATH); + } + else + { + DevInstallParams.Flags &= ~DI_ENUMSINGLEINF; + *DevInstallParams.DriverPath = '\0'; + } - ret = SetupDiSetDeviceInstallParamsW( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - &DevInstallParams); - if (!ret) - { - TRACE("SetupDiSetDeviceInstallParams() failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiSetDeviceInstallParamsW( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + &DevInstallParams); + if (!ret) + { + TRACE("SetupDiSetDeviceInstallParams() failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiBuildDriverInfoList( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDIT_COMPATDRIVER); - if (!ret) - { - TRACE("SetupDiBuildDriverInfoList() failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiBuildDriverInfoList( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDIT_COMPATDRIVER); + if (!ret) + { + TRACE("SetupDiBuildDriverInfoList() failed with error 0x%x\n", GetLastError()); + return FALSE; + } - DevInstData->drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA); - ret = SetupDiEnumDriverInfoW( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDIT_COMPATDRIVER, - 0, - &DevInstData->drvInfoData); - if (!ret) - { - if (GetLastError() == ERROR_NO_MORE_ITEMS) - return FALSE; - TRACE("SetupDiEnumDriverInfo() failed with error 0x%x\n", GetLastError()); - return FALSE; - } + DevInstData->drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA); + ret = SetupDiEnumDriverInfoW( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDIT_COMPATDRIVER, + 0, + &DevInstData->drvInfoData); + if (!ret) + { + if (GetLastError() == ERROR_NO_MORE_ITEMS) + return FALSE; + TRACE("SetupDiEnumDriverInfo() failed with error 0x%x\n", GetLastError()); + return FALSE; + } - return TRUE; + return TRUE; } static BOOL IsDots(IN LPCWSTR str) { - if(wcscmp(str, L".") && wcscmp(str, L"..")) return FALSE; - return TRUE; + if(wcscmp(str, L".") && wcscmp(str, L"..")) return FALSE; + return TRUE; } static LPCWSTR GetFileExt(IN LPWSTR FileName) { - LPCWSTR Dot; + LPCWSTR Dot; - Dot = wcsrchr(FileName, '.'); - if (!Dot) - return L""; + Dot = wcsrchr(FileName, '.'); + if (!Dot) + return L""; - return Dot; + return Dot; } static BOOL SearchDriverRecursive( - IN PDEVINSTDATA DevInstData, - IN LPCWSTR Path) + IN PDEVINSTDATA DevInstData, + IN LPCWSTR Path) { - WIN32_FIND_DATAW wfd; - WCHAR DirPath[MAX_PATH]; - WCHAR FileName[MAX_PATH]; - WCHAR FullPath[MAX_PATH]; - WCHAR LastDirPath[MAX_PATH] = L""; - WCHAR PathWithPattern[MAX_PATH]; - BOOL ok = TRUE; - BOOL retval = FALSE; - HANDLE hFindFile = INVALID_HANDLE_VALUE; + WIN32_FIND_DATAW wfd; + WCHAR DirPath[MAX_PATH]; + WCHAR FileName[MAX_PATH]; + WCHAR FullPath[MAX_PATH]; + WCHAR LastDirPath[MAX_PATH] = L""; + WCHAR PathWithPattern[MAX_PATH]; + BOOL ok = TRUE; + BOOL retval = FALSE; + HANDLE hFindFile = INVALID_HANDLE_VALUE; - wcscpy(DirPath, Path); + wcscpy(DirPath, Path); - if (DirPath[wcslen(DirPath) - 1] != '\\') - wcscat(DirPath, L"\\"); + if (DirPath[wcslen(DirPath) - 1] != '\\') + wcscat(DirPath, L"\\"); - wcscpy(PathWithPattern, DirPath); - wcscat(PathWithPattern, L"\\*"); + wcscpy(PathWithPattern, DirPath); + wcscat(PathWithPattern, L"\\*"); - for (hFindFile = FindFirstFileW(PathWithPattern, &wfd); - ok && hFindFile != INVALID_HANDLE_VALUE; - ok = FindNextFileW(hFindFile, &wfd)) - { + for (hFindFile = FindFirstFileW(PathWithPattern, &wfd); + ok && hFindFile != INVALID_HANDLE_VALUE; + ok = FindNextFileW(hFindFile, &wfd)) + { - wcscpy(FileName, wfd.cFileName); - if (IsDots(FileName)) - continue; + wcscpy(FileName, wfd.cFileName); + if (IsDots(FileName)) + continue; - if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - /* Recursive search */ - wcscpy(FullPath, DirPath); - wcscat(FullPath, FileName); - if (SearchDriverRecursive(DevInstData, FullPath)) - { - retval = TRUE; - /* We continue the search for a better driver */ - } - } - else - { - LPCWSTR pszExtension = GetFileExt(FileName); + if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + /* Recursive search */ + wcscpy(FullPath, DirPath); + wcscat(FullPath, FileName); + if (SearchDriverRecursive(DevInstData, FullPath)) + { + retval = TRUE; + /* We continue the search for a better driver */ + } + } + else + { + LPCWSTR pszExtension = GetFileExt(FileName); - if ((_wcsicmp(pszExtension, L".inf") == 0) && (wcscmp(LastDirPath, DirPath) != 0)) - { - wcscpy(LastDirPath, DirPath); + if ((_wcsicmp(pszExtension, L".inf") == 0) && (wcscmp(LastDirPath, DirPath) != 0)) + { + wcscpy(LastDirPath, DirPath); - if (wcslen(DirPath) > MAX_PATH) - /* Path is too long to be searched */ - continue; + if (wcslen(DirPath) > MAX_PATH) + /* Path is too long to be searched */ + continue; - if (SearchDriver(DevInstData, DirPath, NULL)) - { - retval = TRUE; - /* We continue the search for a better driver */ - } + if (SearchDriver(DevInstData, DirPath, NULL)) + { + retval = TRUE; + /* We continue the search for a better driver */ + } - } - } - } + } + } + } - if (hFindFile != INVALID_HANDLE_VALUE) - FindClose(hFindFile); - return retval; + if (hFindFile != INVALID_HANDLE_VALUE) + FindClose(hFindFile); + return retval; } BOOL ScanFoldersForDriver( - IN PDEVINSTDATA DevInstData) + IN PDEVINSTDATA DevInstData) { - BOOL result; + BOOL result; - /* Search in default location */ - result = SearchDriver(DevInstData, NULL, NULL); + /* Search in default location */ + result = SearchDriver(DevInstData, NULL, NULL); - if (DevInstData->CustomSearchPath) - { - /* Search only in specified paths */ - /* We need to check all specified directories to be - * sure to find the best driver for the device. - */ - LPCWSTR Path; - for (Path = DevInstData->CustomSearchPath; *Path != '\0'; Path += wcslen(Path) + 1) - { - TRACE("Search driver in %s\n", debugstr_w(Path)); - if (wcslen(Path) == 2 && Path[1] == ':') - { - if (SearchDriverRecursive(DevInstData, Path)) - result = TRUE; - } - else - { - if (SearchDriver(DevInstData, Path, NULL)) - result = TRUE; - } - } - } + if (DevInstData->CustomSearchPath) + { + /* Search only in specified paths */ + /* We need to check all specified directories to be + * sure to find the best driver for the device. + */ + LPCWSTR Path; + for (Path = DevInstData->CustomSearchPath; *Path != '\0'; Path += wcslen(Path) + 1) + { + TRACE("Search driver in %s\n", debugstr_w(Path)); + if (wcslen(Path) == 2 && Path[1] == ':') + { + if (SearchDriverRecursive(DevInstData, Path)) + result = TRUE; + } + else + { + if (SearchDriver(DevInstData, Path, NULL)) + result = TRUE; + } + } + } - return result; + return result; } BOOL PrepareFoldersToScan( - IN PDEVINSTDATA DevInstData, - IN BOOL IncludeRemovableDevices, - IN BOOL IncludeCustomPath, - IN HWND hwndCombo OPTIONAL) + IN PDEVINSTDATA DevInstData, + IN BOOL IncludeRemovableDevices, + IN BOOL IncludeCustomPath, + IN HWND hwndCombo OPTIONAL) { - WCHAR drive[] = {'?',':',0}; - DWORD dwDrives = 0; - DWORD i; - UINT nType; - DWORD CustomTextLength = 0; - DWORD LengthNeeded = 0; - LPWSTR Buffer; + WCHAR drive[] = {'?',':',0}; + DWORD dwDrives = 0; + DWORD i; + UINT nType; + DWORD CustomTextLength = 0; + DWORD LengthNeeded = 0; + LPWSTR Buffer; - /* Calculate length needed to store the search paths */ - if (IncludeRemovableDevices) - { - dwDrives = GetLogicalDrives(); - for (drive[0] = 'A', i = 1; drive[0] <= 'Z'; drive[0]++, i <<= 1) - { - if (dwDrives & i) - { - nType = GetDriveTypeW(drive); - if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM) - { - LengthNeeded += 3; - } - } - } - } - if (IncludeCustomPath) - { - CustomTextLength = 1 + ComboBox_GetTextLength(hwndCombo); - LengthNeeded += CustomTextLength; - } + /* Calculate length needed to store the search paths */ + if (IncludeRemovableDevices) + { + dwDrives = GetLogicalDrives(); + for (drive[0] = 'A', i = 1; drive[0] <= 'Z'; drive[0]++, i <<= 1) + { + if (dwDrives & i) + { + nType = GetDriveTypeW(drive); + if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM) + { + LengthNeeded += 3; + } + } + } + } + if (IncludeCustomPath) + { + CustomTextLength = 1 + ComboBox_GetTextLength(hwndCombo); + LengthNeeded += CustomTextLength; + } - /* Allocate space for search paths */ - HeapFree(GetProcessHeap(), 0, DevInstData->CustomSearchPath); - DevInstData->CustomSearchPath = Buffer = HeapAlloc( - GetProcessHeap(), - 0, - (LengthNeeded + 1) * sizeof(WCHAR)); - if (!Buffer) - { - TRACE("HeapAlloc() failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } + /* Allocate space for search paths */ + HeapFree(GetProcessHeap(), 0, DevInstData->CustomSearchPath); + DevInstData->CustomSearchPath = Buffer = HeapAlloc( + GetProcessHeap(), + 0, + (LengthNeeded + 1) * sizeof(WCHAR)); + if (!Buffer) + { + TRACE("HeapAlloc() failed\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } - /* Fill search paths */ - if (IncludeRemovableDevices) - { - for (drive[0] = 'A', i = 1; drive[0] <= 'Z'; drive[0]++, i <<= 1) - { - if (dwDrives & i) - { - nType = GetDriveTypeW(drive); - if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM) - { - Buffer += 1 + swprintf(Buffer, drive); - } - } - } - } - if (IncludeCustomPath) - { - Buffer += 1 + GetWindowTextW(hwndCombo, Buffer, CustomTextLength); - } - *Buffer = '\0'; + /* Fill search paths */ + if (IncludeRemovableDevices) + { + for (drive[0] = 'A', i = 1; drive[0] <= 'Z'; drive[0]++, i <<= 1) + { + if (dwDrives & i) + { + nType = GetDriveTypeW(drive); + if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM) + { + Buffer += 1 + swprintf(Buffer, drive); + } + } + } + } + if (IncludeCustomPath) + { + Buffer += 1 + GetWindowTextW(hwndCombo, Buffer, CustomTextLength); + } + *Buffer = '\0'; - return TRUE; + return TRUE; } BOOL InstallCurrentDriver( - IN PDEVINSTDATA DevInstData) + IN PDEVINSTDATA DevInstData) { - BOOL ret; + BOOL ret; - TRACE("Installing driver %s: %s\n", - debugstr_w(DevInstData->drvInfoData.MfgName), - debugstr_w(DevInstData->drvInfoData.Description)); + TRACE("Installing driver %s: %s\n", + debugstr_w(DevInstData->drvInfoData.MfgName), + debugstr_w(DevInstData->drvInfoData.Description)); - ret = SetupDiCallClassInstaller( - DIF_SELECTBESTCOMPATDRV, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_SELECTBESTCOMPATDRV, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_ALLOW_INSTALL, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_ALLOW_INSTALL, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_NEWDEVICEWIZARD_PREANALYZE, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_NEWDEVICEWIZARD_PREANALYZE, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_NEWDEVICEWIZARD_POSTANALYZE, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_NEWDEVICEWIZARD_POSTANALYZE, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_INSTALLDEVICEFILES, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_INSTALLDEVICEFILES, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_REGISTER_COINSTALLERS, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_REGISTER_COINSTALLERS, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_INSTALLINTERFACES, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_INSTALLINTERFACES, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_INSTALLDEVICE, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_INSTALLDEVICE, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_NEWDEVICEWIZARD_FINISHINSTALL, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_NEWDEVICEWIZARD_FINISHINSTALL, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - ret = SetupDiCallClassInstaller( - DIF_DESTROYPRIVATEDATA, - DevInstData->hDevInfo, - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%x\n", GetLastError()); - return FALSE; - } + ret = SetupDiCallClassInstaller( + DIF_DESTROYPRIVATEDATA, + DevInstData->hDevInfo, + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%x\n", GetLastError()); + return FALSE; + } - return TRUE; + return TRUE; } /* @@ -634,173 +634,173 @@ InstallCurrentDriver( */ BOOL WINAPI DevInstallW( - IN HWND hWndParent, - IN HINSTANCE hInstance, - IN LPCWSTR InstanceId, - IN INT Show) + IN HWND hWndParent, + IN HINSTANCE hInstance, + IN LPCWSTR InstanceId, + IN INT Show) { - PDEVINSTDATA DevInstData = NULL; - BOOL ret; - DWORD config_flags; - BOOL retval = FALSE; + PDEVINSTDATA DevInstData = NULL; + BOOL ret; + DWORD config_flags; + BOOL retval = FALSE; - TRACE("(%p, %p, %s, %d)\n", hWndParent, hInstance, debugstr_w(InstanceId), Show); + TRACE("(%p, %p, %s, %d)\n", hWndParent, hInstance, debugstr_w(InstanceId), Show); - if (!IsUserAdmin()) - { - /* XP kills the process... */ - ExitProcess(ERROR_ACCESS_DENIED); - } + if (!IsUserAdmin()) + { + /* XP kills the process... */ + ExitProcess(ERROR_ACCESS_DENIED); + } - DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA)); - if (!DevInstData) - { - TRACE("HeapAlloc() failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - goto cleanup; - } + DevInstData = HeapAlloc(GetProcessHeap(), 0, sizeof(DEVINSTDATA)); + if (!DevInstData) + { + TRACE("HeapAlloc() failed\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + goto cleanup; + } - /* Clear devinst data */ - ZeroMemory(DevInstData, sizeof(DEVINSTDATA)); - DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */ + /* Clear devinst data */ + ZeroMemory(DevInstData, sizeof(DEVINSTDATA)); + DevInstData->devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */ - /* Fill devinst data */ - DevInstData->hDevInfo = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL); - if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE) - { - TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError()); - goto cleanup; - } + /* Fill devinst data */ + DevInstData->hDevInfo = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL); + if (DevInstData->hDevInfo == INVALID_HANDLE_VALUE) + { + TRACE("SetupDiCreateDeviceInfoListExW() failed with error 0x%x\n", GetLastError()); + goto cleanup; + } - DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - ret = SetupDiOpenDeviceInfoW( - DevInstData->hDevInfo, - InstanceId, - NULL, - 0, /* Open flags */ - &DevInstData->devInfoData); - if (!ret) - { - TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n", - GetLastError(), debugstr_w(InstanceId)); - DevInstData->devInfoData.cbSize = 0; - goto cleanup; - } + DevInstData->devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + ret = SetupDiOpenDeviceInfoW( + DevInstData->hDevInfo, + InstanceId, + NULL, + 0, /* Open flags */ + &DevInstData->devInfoData); + if (!ret) + { + TRACE("SetupDiOpenDeviceInfoW() failed with error 0x%x (InstanceId %s)\n", + GetLastError(), debugstr_w(InstanceId)); + DevInstData->devInfoData.cbSize = 0; + goto cleanup; + } - SetLastError(ERROR_GEN_FAILURE); - ret = SetupDiGetDeviceRegistryProperty( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDRP_DEVICEDESC, - &DevInstData->regDataType, - NULL, 0, - &DevInstData->requiredSize); + SetLastError(ERROR_GEN_FAILURE); + ret = SetupDiGetDeviceRegistryProperty( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDRP_DEVICEDESC, + &DevInstData->regDataType, + NULL, 0, + &DevInstData->requiredSize); - if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ) - { - DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize); - if (!DevInstData->buffer) - { - TRACE("HeapAlloc() failed\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - } - else - { - ret = SetupDiGetDeviceRegistryPropertyW( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDRP_DEVICEDESC, - &DevInstData->regDataType, - DevInstData->buffer, DevInstData->requiredSize, - &DevInstData->requiredSize); - } - } - if (!ret) - { - TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n", - GetLastError(), debugstr_w(InstanceId)); - goto cleanup; - } + if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER && DevInstData->regDataType == REG_SZ) + { + DevInstData->buffer = HeapAlloc(GetProcessHeap(), 0, DevInstData->requiredSize); + if (!DevInstData->buffer) + { + TRACE("HeapAlloc() failed\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + } + else + { + ret = SetupDiGetDeviceRegistryPropertyW( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDRP_DEVICEDESC, + &DevInstData->regDataType, + DevInstData->buffer, DevInstData->requiredSize, + &DevInstData->requiredSize); + } + } + if (!ret) + { + TRACE("SetupDiGetDeviceRegistryProperty() failed with error 0x%x (InstanceId %s)\n", + GetLastError(), debugstr_w(InstanceId)); + goto cleanup; + } - if (SetupDiGetDeviceRegistryPropertyW( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDRP_CONFIGFLAGS, - NULL, - (BYTE *)&config_flags, - sizeof(config_flags), - NULL)) - { - if (config_flags & CONFIGFLAG_FAILEDINSTALL) - { - /* The device is disabled */ - TRACE("Device is disabled\n"); - retval = TRUE; - goto cleanup; - } - } + if (SetupDiGetDeviceRegistryPropertyW( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDRP_CONFIGFLAGS, + NULL, + (BYTE *)&config_flags, + sizeof(config_flags), + NULL)) + { + if (config_flags & CONFIGFLAG_FAILEDINSTALL) + { + /* The device is disabled */ + TRACE("Device is disabled\n"); + retval = TRUE; + goto cleanup; + } + } - TRACE("Installing %s (%s)\n", debugstr_w((PCWSTR)DevInstData->buffer), debugstr_w(InstanceId)); + TRACE("Installing %s (%s)\n", debugstr_w((PCWSTR)DevInstData->buffer), debugstr_w(InstanceId)); - /* Search driver in default location and removable devices */ - if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL)) - { - TRACE("PrepareFoldersToScan() failed with error 0x%lx\n", GetLastError()); - goto cleanup; - } - if (ScanFoldersForDriver(DevInstData)) - { - /* Driver found ; install it */ - retval = InstallCurrentDriver(DevInstData); - TRACE("InstallCurrentDriver() returned %d\n", retval); - if (retval && Show != SW_HIDE) - { - /* Should we display the 'Need to reboot' page? */ - SP_DEVINSTALL_PARAMS installParams; - installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); - if (SetupDiGetDeviceInstallParams( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - &installParams)) - { - if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT)) - { - TRACE("Displaying 'Reboot' wizard page\n"); - retval = DisplayWizard(DevInstData, hWndParent, IDD_NEEDREBOOT); - } - } - } - goto cleanup; - } - else if (Show == SW_HIDE) - { - /* We can't show the wizard. Fail the install */ - TRACE("No wizard\n"); - goto cleanup; - } + /* Search driver in default location and removable devices */ + if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL)) + { + TRACE("PrepareFoldersToScan() failed with error 0x%lx\n", GetLastError()); + goto cleanup; + } + if (ScanFoldersForDriver(DevInstData)) + { + /* Driver found ; install it */ + retval = InstallCurrentDriver(DevInstData); + TRACE("InstallCurrentDriver() returned %d\n", retval); + if (retval && Show != SW_HIDE) + { + /* Should we display the 'Need to reboot' page? */ + SP_DEVINSTALL_PARAMS installParams; + installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); + if (SetupDiGetDeviceInstallParams( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + &installParams)) + { + if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT)) + { + TRACE("Displaying 'Reboot' wizard page\n"); + retval = DisplayWizard(DevInstData, hWndParent, IDD_NEEDREBOOT); + } + } + } + goto cleanup; + } + else if (Show == SW_HIDE) + { + /* We can't show the wizard. Fail the install */ + TRACE("No wizard\n"); + goto cleanup; + } - /* Prepare the wizard, and display it */ - TRACE("Need to show install wizard\n"); - retval = DisplayWizard(DevInstData, hWndParent, IDD_WELCOMEPAGE); + /* Prepare the wizard, and display it */ + TRACE("Need to show install wizard\n"); + retval = DisplayWizard(DevInstData, hWndParent, IDD_WELCOMEPAGE); cleanup: - if (DevInstData) - { - if (DevInstData->devInfoData.cbSize != 0) - { - if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER)) - TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError()); - } - if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE) - { - if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo)) - TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError()); - } - HeapFree(GetProcessHeap(), 0, DevInstData->buffer); - HeapFree(GetProcessHeap(), 0, DevInstData); - } + if (DevInstData) + { + if (DevInstData->devInfoData.cbSize != 0) + { + if (!SetupDiDestroyDriverInfoList(DevInstData->hDevInfo, &DevInstData->devInfoData, SPDIT_COMPATDRIVER)) + TRACE("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError()); + } + if (DevInstData->hDevInfo != INVALID_HANDLE_VALUE) + { + if (!SetupDiDestroyDeviceInfoList(DevInstData->hDevInfo)) + TRACE("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError()); + } + HeapFree(GetProcessHeap(), 0, DevInstData->buffer); + HeapFree(GetProcessHeap(), 0, DevInstData); + } - return retval; + return retval; } /* @@ -808,9 +808,9 @@ cleanup: */ BOOL WINAPI ClientSideInstallW( - IN HWND hWndOwner, - IN DWORD dwUnknownFlags, - IN LPWSTR lpNamedPipeName) + IN HWND hWndOwner, + IN DWORD dwUnknownFlags, + IN LPWSTR lpNamedPipeName) { BOOL ReturnValue = FALSE; BOOL ShowWizard; @@ -885,21 +885,21 @@ cleanup: BOOL WINAPI DllMain( - IN HINSTANCE hInstance, - IN DWORD dwReason, - IN LPVOID lpReserved) + IN HINSTANCE hInstance, + IN DWORD dwReason, + IN LPVOID lpReserved) { - if (dwReason == DLL_PROCESS_ATTACH) - { - INITCOMMONCONTROLSEX InitControls; + if (dwReason == DLL_PROCESS_ATTACH) + { + INITCOMMONCONTROLSEX InitControls; - DisableThreadLibraryCalls(hInstance); + DisableThreadLibraryCalls(hInstance); - InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX); - InitControls.dwICC = ICC_PROGRESS_CLASS; - InitCommonControlsEx(&InitControls); - hDllInstance = hInstance; - } + InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX); + InitControls.dwICC = ICC_PROGRESS_CLASS; + InitCommonControlsEx(&InitControls); + hDllInstance = hInstance; + } - return TRUE; + return TRUE; } diff --git a/reactos/dll/win32/newdev/stubs.c b/reactos/dll/win32/newdev/stubs.c index ba846aa20b5..13acf5a65d5 100644 --- a/reactos/dll/win32/newdev/stubs.c +++ b/reactos/dll/win32/newdev/stubs.c @@ -27,13 +27,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(newdev); */ BOOL WINAPI InstallNewDevice( - IN HWND hwndParent, - IN LPGUID ClassGuid OPTIONAL, - OUT PDWORD Reboot) + IN HWND hwndParent, + IN LPGUID ClassGuid OPTIONAL, + OUT PDWORD Reboot) { - UNIMPLEMENTED; - SetLastError(ERROR_GEN_FAILURE); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_GEN_FAILURE); + return FALSE; } /* @@ -41,15 +41,15 @@ InstallNewDevice( */ BOOL WINAPI InstallSelectedDriverW( - IN HWND hwndParent, - IN HDEVINFO DeviceInfoSet, - IN LPCWSTR Reserved, - IN BOOL Backup, - OUT PDWORD pReboot) + IN HWND hwndParent, + IN HDEVINFO DeviceInfoSet, + IN LPCWSTR Reserved, + IN BOOL Backup, + OUT PDWORD pReboot) { - UNIMPLEMENTED; - SetLastError(ERROR_GEN_FAILURE); - return FALSE; + UNIMPLEMENTED; + SetLastError(ERROR_GEN_FAILURE); + return FALSE; } /* diff --git a/reactos/dll/win32/newdev/wizard.c b/reactos/dll/win32/newdev/wizard.c index 44813f71649..57d9a4c768a 100644 --- a/reactos/dll/win32/newdev/wizard.c +++ b/reactos/dll/win32/newdev/wizard.c @@ -26,1297 +26,1297 @@ HANDLE hThread; static VOID CenterWindow( - IN HWND hWnd) + IN HWND hWnd) { - HWND hWndParent; - RECT rcParent; - RECT rcWindow; + HWND hWndParent; + RECT rcParent; + RECT rcWindow; - hWndParent = GetParent(hWnd); - if (hWndParent == NULL) - hWndParent = GetDesktopWindow(); + hWndParent = GetParent(hWnd); + if (hWndParent == NULL) + hWndParent = GetDesktopWindow(); - GetWindowRect(hWndParent, &rcParent); - GetWindowRect(hWnd, &rcWindow); + GetWindowRect(hWndParent, &rcParent); + GetWindowRect(hWnd, &rcWindow); - SetWindowPos( - hWnd, - HWND_TOP, - ((rcParent.right - rcParent.left) - (rcWindow.right - rcWindow.left)) / 2, - ((rcParent.bottom - rcParent.top) - (rcWindow.bottom - rcWindow.top)) / 2, - 0, - 0, - SWP_NOSIZE); + SetWindowPos( + hWnd, + HWND_TOP, + ((rcParent.right - rcParent.left) - (rcWindow.right - rcWindow.left)) / 2, + ((rcParent.bottom - rcParent.top) - (rcWindow.bottom - rcWindow.top)) / 2, + 0, + 0, + SWP_NOSIZE); } static BOOL CanDisableDevice( - IN DEVINST DevInst, - IN HMACHINE hMachine, - OUT BOOL *CanDisable) + IN DEVINST DevInst, + IN HMACHINE hMachine, + OUT BOOL *CanDisable) { - CONFIGRET cr; - ULONG Status, ProblemNumber; - BOOL Ret = FALSE; + CONFIGRET cr; + ULONG Status, ProblemNumber; + BOOL Ret = FALSE; - cr = CM_Get_DevNode_Status_Ex(&Status, + cr = CM_Get_DevNode_Status_Ex(&Status, &ProblemNumber, DevInst, 0, hMachine); - if (cr == CR_SUCCESS) - { - *CanDisable = ((Status & DN_DISABLEABLE) != 0); + if (cr == CR_SUCCESS) + { + *CanDisable = ((Status & DN_DISABLEABLE) != 0); Ret = TRUE; - } + } - return Ret; + return Ret; } static BOOL IsDeviceStarted( - IN DEVINST DevInst, - IN HMACHINE hMachine, - OUT BOOL *IsEnabled) + IN DEVINST DevInst, + IN HMACHINE hMachine, + OUT BOOL *IsEnabled) { - CONFIGRET cr; - ULONG Status, ProblemNumber; - BOOL Ret = FALSE; + CONFIGRET cr; + ULONG Status, ProblemNumber; + BOOL Ret = FALSE; - cr = CM_Get_DevNode_Status_Ex( - &Status, - &ProblemNumber, - DevInst, - 0, - hMachine); - if (cr == CR_SUCCESS) - { - *IsEnabled = ((Status & DN_STARTED) != 0); - Ret = TRUE; - } + cr = CM_Get_DevNode_Status_Ex( + &Status, + &ProblemNumber, + DevInst, + 0, + hMachine); + if (cr == CR_SUCCESS) + { + *IsEnabled = ((Status & DN_STARTED) != 0); + Ret = TRUE; + } - return Ret; + return Ret; } static BOOL StartDevice( - IN HDEVINFO DeviceInfoSet, - IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, - IN BOOL bEnable, - IN DWORD HardwareProfile OPTIONAL, - OUT BOOL *bNeedReboot OPTIONAL) + IN HDEVINFO DeviceInfoSet, + IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, + IN BOOL bEnable, + IN DWORD HardwareProfile OPTIONAL, + OUT BOOL *bNeedReboot OPTIONAL) { - SP_PROPCHANGE_PARAMS pcp; - SP_DEVINSTALL_PARAMS dp; - DWORD LastErr; - BOOL Ret = FALSE; + SP_PROPCHANGE_PARAMS pcp; + SP_DEVINSTALL_PARAMS dp; + DWORD LastErr; + BOOL Ret = FALSE; - pcp.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); - pcp.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; - pcp.HwProfile = HardwareProfile; + pcp.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); + pcp.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; + pcp.HwProfile = HardwareProfile; - if (bEnable) - { - /* try to enable the device on the global profile */ - pcp.StateChange = DICS_ENABLE; - pcp.Scope = DICS_FLAG_GLOBAL; + if (bEnable) + { + /* try to enable the device on the global profile */ + pcp.StateChange = DICS_ENABLE; + pcp.Scope = DICS_FLAG_GLOBAL; - /* ignore errors */ - LastErr = GetLastError(); - if (SetupDiSetClassInstallParams( - DeviceInfoSet, - DevInfoData, - &pcp.ClassInstallHeader, - sizeof(SP_PROPCHANGE_PARAMS))) - { - SetupDiCallClassInstaller( - DIF_PROPERTYCHANGE, - DeviceInfoSet, - DevInfoData); - } - SetLastError(LastErr); - } + /* ignore errors */ + LastErr = GetLastError(); + if (SetupDiSetClassInstallParams( + DeviceInfoSet, + DevInfoData, + &pcp.ClassInstallHeader, + sizeof(SP_PROPCHANGE_PARAMS))) + { + SetupDiCallClassInstaller( + DIF_PROPERTYCHANGE, + DeviceInfoSet, + DevInfoData); + } + SetLastError(LastErr); + } - /* try config-specific */ - pcp.StateChange = (bEnable ? DICS_ENABLE : DICS_DISABLE); - pcp.Scope = DICS_FLAG_CONFIGSPECIFIC; + /* try config-specific */ + pcp.StateChange = (bEnable ? DICS_ENABLE : DICS_DISABLE); + pcp.Scope = DICS_FLAG_CONFIGSPECIFIC; - if (SetupDiSetClassInstallParams( - DeviceInfoSet, - DevInfoData, - &pcp.ClassInstallHeader, - sizeof(SP_PROPCHANGE_PARAMS)) && - SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, - DeviceInfoSet, - DevInfoData)) - { - dp.cbSize = sizeof(SP_DEVINSTALL_PARAMS); - if (SetupDiGetDeviceInstallParams( - DeviceInfoSet, - DevInfoData, - &dp)) - { - if (bNeedReboot != NULL) - { - *bNeedReboot = ((dp.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT)) != 0); - } + if (SetupDiSetClassInstallParams( + DeviceInfoSet, + DevInfoData, + &pcp.ClassInstallHeader, + sizeof(SP_PROPCHANGE_PARAMS)) && + SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, + DeviceInfoSet, + DevInfoData)) + { + dp.cbSize = sizeof(SP_DEVINSTALL_PARAMS); + if (SetupDiGetDeviceInstallParams( + DeviceInfoSet, + DevInfoData, + &dp)) + { + if (bNeedReboot != NULL) + { + *bNeedReboot = ((dp.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT)) != 0); + } - Ret = TRUE; - } - } - return Ret; + Ret = TRUE; + } + } + return Ret; } static DWORD WINAPI FindDriverProc( - IN LPVOID lpParam) + IN LPVOID lpParam) { - PDEVINSTDATA DevInstData; - DWORD config_flags; - BOOL result = FALSE; + PDEVINSTDATA DevInstData; + DWORD config_flags; + BOOL result = FALSE; - DevInstData = (PDEVINSTDATA)lpParam; + DevInstData = (PDEVINSTDATA)lpParam; - result = ScanFoldersForDriver(DevInstData); + result = ScanFoldersForDriver(DevInstData); - if (result) - { - PostMessage(DevInstData->hDialog, WM_SEARCH_FINISHED, 1, 0); - } - else - { - /* Update device configuration */ - if (SetupDiGetDeviceRegistryProperty( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDRP_CONFIGFLAGS, - NULL, - (BYTE *)&config_flags, - sizeof(config_flags), - NULL)) - { - config_flags |= CONFIGFLAG_FAILEDINSTALL; - SetupDiSetDeviceRegistryPropertyW( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDRP_CONFIGFLAGS, - (BYTE *)&config_flags, sizeof(config_flags)); - } + if (result) + { + PostMessage(DevInstData->hDialog, WM_SEARCH_FINISHED, 1, 0); + } + else + { + /* Update device configuration */ + if (SetupDiGetDeviceRegistryProperty( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDRP_CONFIGFLAGS, + NULL, + (BYTE *)&config_flags, + sizeof(config_flags), + NULL)) + { + config_flags |= CONFIGFLAG_FAILEDINSTALL; + SetupDiSetDeviceRegistryPropertyW( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDRP_CONFIGFLAGS, + (BYTE *)&config_flags, sizeof(config_flags)); + } - PostMessage(DevInstData->hDialog, WM_SEARCH_FINISHED, 0, 0); - } - return 0; + PostMessage(DevInstData->hDialog, WM_SEARCH_FINISHED, 0, 0); + } + return 0; } static DWORD WINAPI InstallDriverProc( - IN LPVOID lpParam) + IN LPVOID lpParam) { - PDEVINSTDATA DevInstData; - BOOL res; + PDEVINSTDATA DevInstData; + BOOL res; - DevInstData = (PDEVINSTDATA)lpParam; - res = InstallCurrentDriver(DevInstData); - PostMessage(DevInstData->hDialog, WM_INSTALL_FINISHED, res ? 0 : 1, 0); - return 0; + DevInstData = (PDEVINSTDATA)lpParam; + res = InstallCurrentDriver(DevInstData); + PostMessage(DevInstData->hDialog, WM_INSTALL_FINISHED, res ? 0 : 1, 0); + return 0; } static VOID PopulateCustomPathCombo( - IN HWND hwndCombo) + IN HWND hwndCombo) { - HKEY hKey = NULL; - DWORD dwRegType; - DWORD dwPathLength = 0; - LPWSTR Buffer = NULL; - LPCWSTR Path; - LONG rc; + HKEY hKey = NULL; + DWORD dwRegType; + DWORD dwPathLength = 0; + LPWSTR Buffer = NULL; + LPCWSTR Path; + LONG rc; - (void)ComboBox_ResetContent(hwndCombo); + (void)ComboBox_ResetContent(hwndCombo); - /* RegGetValue would have been better... */ - rc = RegOpenKeyEx( - HKEY_LOCAL_MACHINE, - REGSTR_PATH_SETUP REGSTR_KEY_SETUP, - 0, - KEY_QUERY_VALUE, - &hKey); - if (rc != ERROR_SUCCESS) - { - TRACE("RegOpenKeyEx() failed with error 0x%lx\n", rc); - goto cleanup; - } - rc = RegQueryValueExW( - hKey, - L"Installation Sources", - NULL, - &dwRegType, - NULL, - &dwPathLength); - if (rc != ERROR_SUCCESS || dwRegType != REG_MULTI_SZ) - { - TRACE("RegQueryValueEx() failed with error 0x%lx\n", rc); - goto cleanup; - } + /* RegGetValue would have been better... */ + rc = RegOpenKeyEx( + HKEY_LOCAL_MACHINE, + REGSTR_PATH_SETUP REGSTR_KEY_SETUP, + 0, + KEY_QUERY_VALUE, + &hKey); + if (rc != ERROR_SUCCESS) + { + TRACE("RegOpenKeyEx() failed with error 0x%lx\n", rc); + goto cleanup; + } + rc = RegQueryValueExW( + hKey, + L"Installation Sources", + NULL, + &dwRegType, + NULL, + &dwPathLength); + if (rc != ERROR_SUCCESS || dwRegType != REG_MULTI_SZ) + { + TRACE("RegQueryValueEx() failed with error 0x%lx\n", rc); + goto cleanup; + } - /* Allocate enough space to add 2 NULL chars at the end of the string */ - Buffer = HeapAlloc(GetProcessHeap(), 0, dwPathLength + 2 * sizeof(WCHAR)); - if (!Buffer) - { - TRACE("HeapAlloc() failed\n"); - goto cleanup; - } - rc = RegQueryValueExW( - hKey, - L"Installation Sources", - NULL, - NULL, - (LPBYTE)Buffer, - &dwPathLength); - if (rc != ERROR_SUCCESS) - { - TRACE("RegQueryValueEx() failed with error 0x%lx\n", rc); - goto cleanup; - } - Buffer[dwPathLength] = Buffer[dwPathLength + 1] = '\0'; + /* Allocate enough space to add 2 NULL chars at the end of the string */ + Buffer = HeapAlloc(GetProcessHeap(), 0, dwPathLength + 2 * sizeof(WCHAR)); + if (!Buffer) + { + TRACE("HeapAlloc() failed\n"); + goto cleanup; + } + rc = RegQueryValueExW( + hKey, + L"Installation Sources", + NULL, + NULL, + (LPBYTE)Buffer, + &dwPathLength); + if (rc != ERROR_SUCCESS) + { + TRACE("RegQueryValueEx() failed with error 0x%lx\n", rc); + goto cleanup; + } + Buffer[dwPathLength] = Buffer[dwPathLength + 1] = '\0'; - /* Populate combo box */ - for (Path = Buffer; *Path; Path += wcslen(Path) + 1) - { - (void)ComboBox_AddString(hwndCombo, Path); - if (Path == Buffer) - (void)ComboBox_SetCurSel(hwndCombo, 0); - } + /* Populate combo box */ + for (Path = Buffer; *Path; Path += wcslen(Path) + 1) + { + (void)ComboBox_AddString(hwndCombo, Path); + if (Path == Buffer) + (void)ComboBox_SetCurSel(hwndCombo, 0); + } cleanup: - if (hKey != NULL) - RegCloseKey(hKey); - HeapFree(GetProcessHeap(), 0, Buffer); + if (hKey != NULL) + RegCloseKey(hKey); + HeapFree(GetProcessHeap(), 0, Buffer); } static VOID SaveCustomPath( - IN HWND hwndCombo) + IN HWND hwndCombo) { - LPWSTR CustomPath = NULL; - DWORD CustomPathLength; - LPWSTR Buffer = NULL; - LPWSTR pBuffer; /* Pointer into Buffer */ - int ItemsCount, Length; - DWORD i; - DWORD TotalLength = 0; - BOOL UseCustomPath = TRUE; - HKEY hKey = NULL; - LONG rc; + LPWSTR CustomPath = NULL; + DWORD CustomPathLength; + LPWSTR Buffer = NULL; + LPWSTR pBuffer; /* Pointer into Buffer */ + int ItemsCount, Length; + DWORD i; + DWORD TotalLength = 0; + BOOL UseCustomPath = TRUE; + HKEY hKey = NULL; + LONG rc; - /* Get custom path */ - Length = ComboBox_GetTextLength(hwndCombo) + 1; - CustomPath = HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR)); - if (!CustomPath) - { - TRACE("HeapAlloc() failed\n"); - goto cleanup; - } - CustomPathLength = GetWindowTextW(hwndCombo, CustomPath, Length) + 1; + /* Get custom path */ + Length = ComboBox_GetTextLength(hwndCombo) + 1; + CustomPath = HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR)); + if (!CustomPath) + { + TRACE("HeapAlloc() failed\n"); + goto cleanup; + } + CustomPathLength = GetWindowTextW(hwndCombo, CustomPath, Length) + 1; - /* Calculate length of the buffer */ - ItemsCount = ComboBox_GetCount(hwndCombo); - if (ItemsCount == CB_ERR) - { - TRACE("ComboBox_GetCount() failed\n"); - goto cleanup; - } - for (i = 0; i < ItemsCount; i++) - { - Length = ComboBox_GetLBTextLen(hwndCombo, i); - if (Length == CB_ERR) - { - TRACE("ComboBox_GetLBTextLen() failed\n"); - goto cleanup; - } - TotalLength += Length + 1; - } - TotalLength++; /* Final NULL char */ + /* Calculate length of the buffer */ + ItemsCount = ComboBox_GetCount(hwndCombo); + if (ItemsCount == CB_ERR) + { + TRACE("ComboBox_GetCount() failed\n"); + goto cleanup; + } + for (i = 0; i < ItemsCount; i++) + { + Length = ComboBox_GetLBTextLen(hwndCombo, i); + if (Length == CB_ERR) + { + TRACE("ComboBox_GetLBTextLen() failed\n"); + goto cleanup; + } + TotalLength += Length + 1; + } + TotalLength++; /* Final NULL char */ - /* Allocate buffer */ - Buffer = HeapAlloc(GetProcessHeap(), 0, (CustomPathLength + TotalLength + 1) * sizeof(WCHAR)); - if (!Buffer) - { - TRACE("HeapAlloc() failed\n"); - goto cleanup; - } + /* Allocate buffer */ + Buffer = HeapAlloc(GetProcessHeap(), 0, (CustomPathLength + TotalLength + 1) * sizeof(WCHAR)); + if (!Buffer) + { + TRACE("HeapAlloc() failed\n"); + goto cleanup; + } - /* Fill the buffer */ - pBuffer = &Buffer[CustomPathLength]; - for (i = 0; i < ItemsCount; i++) - { - Length = ComboBox_GetLBText(hwndCombo, i, pBuffer); - if (Length == CB_ERR) - { - TRACE("ComboBox_GetLBText() failed\n"); - goto cleanup; - } - else if (UseCustomPath && _wcsicmp(CustomPath, pBuffer) == 0) - UseCustomPath = FALSE; - pBuffer += 1 + Length; - } - *pBuffer = '\0'; /* Add final NULL char */ + /* Fill the buffer */ + pBuffer = &Buffer[CustomPathLength]; + for (i = 0; i < ItemsCount; i++) + { + Length = ComboBox_GetLBText(hwndCombo, i, pBuffer); + if (Length == CB_ERR) + { + TRACE("ComboBox_GetLBText() failed\n"); + goto cleanup; + } + else if (UseCustomPath && _wcsicmp(CustomPath, pBuffer) == 0) + UseCustomPath = FALSE; + pBuffer += 1 + Length; + } + *pBuffer = '\0'; /* Add final NULL char */ - if (!UseCustomPath) - { - /* Nothing to save to registry */ - goto cleanup; - } + if (!UseCustomPath) + { + /* Nothing to save to registry */ + goto cleanup; + } - TotalLength += CustomPathLength; - wcscpy(Buffer, CustomPath); + TotalLength += CustomPathLength; + wcscpy(Buffer, CustomPath); - /* Save the buffer */ - /* RegSetKeyValue would have been better... */ - rc = RegOpenKeyEx( - HKEY_LOCAL_MACHINE, - REGSTR_PATH_SETUP REGSTR_KEY_SETUP, - 0, - KEY_SET_VALUE, - &hKey); - if (rc != ERROR_SUCCESS) - { - TRACE("RegOpenKeyEx() failed with error 0x%lx\n", rc); - goto cleanup; - } - rc = RegSetValueExW( - hKey, - L"Installation Sources", - 0, - REG_MULTI_SZ, - (const BYTE*)Buffer, - TotalLength * sizeof(WCHAR)); - if (rc != ERROR_SUCCESS) - { - TRACE("RegSetValueEx() failed with error 0x%lx\n", rc); - goto cleanup; - } + /* Save the buffer */ + /* RegSetKeyValue would have been better... */ + rc = RegOpenKeyEx( + HKEY_LOCAL_MACHINE, + REGSTR_PATH_SETUP REGSTR_KEY_SETUP, + 0, + KEY_SET_VALUE, + &hKey); + if (rc != ERROR_SUCCESS) + { + TRACE("RegOpenKeyEx() failed with error 0x%lx\n", rc); + goto cleanup; + } + rc = RegSetValueExW( + hKey, + L"Installation Sources", + 0, + REG_MULTI_SZ, + (const BYTE*)Buffer, + TotalLength * sizeof(WCHAR)); + if (rc != ERROR_SUCCESS) + { + TRACE("RegSetValueEx() failed with error 0x%lx\n", rc); + goto cleanup; + } cleanup: - if (hKey != NULL) - RegCloseKey(hKey); - HeapFree(GetProcessHeap(), 0, CustomPath); - HeapFree(GetProcessHeap(), 0, Buffer); + if (hKey != NULL) + RegCloseKey(hKey); + HeapFree(GetProcessHeap(), 0, CustomPath); + HeapFree(GetProcessHeap(), 0, Buffer); } static INT_PTR CALLBACK WelcomeDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; - UNREFERENCED_PARAMETER(wParam); + PDEVINSTDATA DevInstData; + UNREFERENCED_PARAMETER(wParam); - /* Retrieve pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Retrieve pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - HWND hwndControl; - DWORD dwStyle; + switch (uMsg) + { + case WM_INITDIALOG: + { + HWND hwndControl; + DWORD dwStyle; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - hwndControl = GetParent(hwndDlg); + hwndControl = GetParent(hwndDlg); - /* Center the wizard window */ - CenterWindow(hwndControl); + /* Center the wizard window */ + CenterWindow(hwndControl); - /* Hide the system menu */ - dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); - SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); + /* Hide the system menu */ + dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); + SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); - /* Set title font */ - SendDlgItemMessage( - hwndDlg, - IDC_WELCOMETITLE, - WM_SETFONT, - (WPARAM)DevInstData->hTitleFont, - (LPARAM)TRUE); + /* Set title font */ + SendDlgItemMessage( + hwndDlg, + IDC_WELCOMETITLE, + WM_SETFONT, + (WPARAM)DevInstData->hTitleFont, + (LPARAM)TRUE); - SendDlgItemMessage( - hwndDlg, - IDC_DEVICE, - WM_SETTEXT, - 0, - (LPARAM)DevInstData->buffer); + SendDlgItemMessage( + hwndDlg, + IDC_DEVICE, + WM_SETTEXT, + 0, + (LPARAM)DevInstData->buffer); - SendDlgItemMessage( - hwndDlg, - IDC_RADIO_AUTO, - BM_SETCHECK, - (WPARAM)TRUE, - (LPARAM)0); - break; - } + SendDlgItemMessage( + hwndDlg, + IDC_RADIO_AUTO, + BM_SETCHECK, + (WPARAM)TRUE, + (LPARAM)0); + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - /* Enable the Next button */ - PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + /* Enable the Next button */ + PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT); + break; - case PSN_WIZNEXT: - /* Handle a Next button click, if necessary */ - if (SendDlgItemMessage(hwndDlg, IDC_RADIO_AUTO, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED) - { - if (PrepareFoldersToScan(DevInstData, TRUE, FALSE, NULL)) - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_SEARCHDRV); - else - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED); - } - return TRUE; + case PSN_WIZNEXT: + /* Handle a Next button click, if necessary */ + if (SendDlgItemMessage(hwndDlg, IDC_RADIO_AUTO, BM_GETCHECK, (WPARAM)0, (LPARAM)0) == BST_CHECKED) + { + if (PrepareFoldersToScan(DevInstData, TRUE, FALSE, NULL)) + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_SEARCHDRV); + else + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED); + } + return TRUE; - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static void IncludePath(HWND Dlg, BOOL Enabled) { - EnableWindow(GetDlgItem(Dlg, IDC_COMBO_PATH), Enabled); - EnableWindow(GetDlgItem(Dlg, IDC_BROWSE), Enabled); + EnableWindow(GetDlgItem(Dlg, IDC_COMBO_PATH), Enabled); + EnableWindow(GetDlgItem(Dlg, IDC_BROWSE), Enabled); } static void AutoDriver(HWND Dlg, BOOL Enabled) { - EnableWindow(GetDlgItem(Dlg, IDC_CHECK_MEDIA), Enabled); - EnableWindow(GetDlgItem(Dlg, IDC_CHECK_PATH), Enabled); - IncludePath(Dlg, Enabled & IsDlgButtonChecked(Dlg, IDC_CHECK_PATH)); + EnableWindow(GetDlgItem(Dlg, IDC_CHECK_MEDIA), Enabled); + EnableWindow(GetDlgItem(Dlg, IDC_CHECK_PATH), Enabled); + IncludePath(Dlg, Enabled & IsDlgButtonChecked(Dlg, IDC_CHECK_PATH)); } static INT_PTR CALLBACK CHSourceDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; + PDEVINSTDATA DevInstData; - /* Retrieve pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Retrieve pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - HWND hwndControl; - DWORD dwStyle; + switch (uMsg) + { + case WM_INITDIALOG: + { + HWND hwndControl; + DWORD dwStyle; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - hwndControl = GetParent(hwndDlg); + hwndControl = GetParent(hwndDlg); - /* Center the wizard window */ - CenterWindow(hwndControl); + /* Center the wizard window */ + CenterWindow(hwndControl); - /* Hide the system menu */ - dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); - SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); + /* Hide the system menu */ + dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); + SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); - PopulateCustomPathCombo(GetDlgItem(hwndDlg, IDC_COMBO_PATH)); + PopulateCustomPathCombo(GetDlgItem(hwndDlg, IDC_COMBO_PATH)); - SendDlgItemMessage( - hwndDlg, - IDC_RADIO_SEARCHHERE, - BM_SETCHECK, - (WPARAM)TRUE, - (LPARAM)0); - AutoDriver(hwndDlg, TRUE); - IncludePath(hwndDlg, FALSE); + SendDlgItemMessage( + hwndDlg, + IDC_RADIO_SEARCHHERE, + BM_SETCHECK, + (WPARAM)TRUE, + (LPARAM)0); + AutoDriver(hwndDlg, TRUE); + IncludePath(hwndDlg, FALSE); - /* Disable manual driver choice for now */ - EnableWindow(GetDlgItem(hwndDlg, IDC_RADIO_CHOOSE), FALSE); + /* Disable manual driver choice for now */ + EnableWindow(GetDlgItem(hwndDlg, IDC_RADIO_CHOOSE), FALSE); - break; - } + break; + } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_RADIO_SEARCHHERE: - AutoDriver(hwndDlg, TRUE); - return TRUE; + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_RADIO_SEARCHHERE: + AutoDriver(hwndDlg, TRUE); + return TRUE; - case IDC_RADIO_CHOOSE: - AutoDriver(hwndDlg, FALSE); - return TRUE; + case IDC_RADIO_CHOOSE: + AutoDriver(hwndDlg, FALSE); + return TRUE; - case IDC_CHECK_PATH: - IncludePath(hwndDlg, IsDlgButtonChecked(hwndDlg, IDC_CHECK_PATH)); - return TRUE; + case IDC_CHECK_PATH: + IncludePath(hwndDlg, IsDlgButtonChecked(hwndDlg, IDC_CHECK_PATH)); + return TRUE; - case IDC_BROWSE: - { - BROWSEINFO bi = { 0 }; - LPITEMIDLIST pidl; + case IDC_BROWSE: + { + BROWSEINFO bi = { 0 }; + LPITEMIDLIST pidl; - bi.hwndOwner = hwndDlg; - bi.ulFlags = BIF_RETURNONLYFSDIRS; - pidl = SHBrowseForFolder(&bi); - if (pidl) - { - WCHAR Directory[MAX_PATH]; - IMalloc* malloc; + bi.hwndOwner = hwndDlg; + bi.ulFlags = BIF_RETURNONLYFSDIRS; + pidl = SHBrowseForFolder(&bi); + if (pidl) + { + WCHAR Directory[MAX_PATH]; + IMalloc* malloc; - if (SHGetPathFromIDListW(pidl, Directory)) - { - /* Set the IDC_COMBO_PATH text */ - SetWindowTextW(GetDlgItem(hwndDlg, IDC_COMBO_PATH), Directory); - } + if (SHGetPathFromIDListW(pidl, Directory)) + { + /* Set the IDC_COMBO_PATH text */ + SetWindowTextW(GetDlgItem(hwndDlg, IDC_COMBO_PATH), Directory); + } - /* Free memory, if possible */ - if (SUCCEEDED(SHGetMalloc(&malloc))) - { - IMalloc_Free(malloc, pidl); - IMalloc_Release(malloc); - } - return TRUE; - } - break; - } - } - break; - } + /* Free memory, if possible */ + if (SUCCEEDED(SHGetMalloc(&malloc))) + { + IMalloc_Free(malloc, pidl); + IMalloc_Release(malloc); + } + return TRUE; + } + break; + } + } + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - /* Enable the Next and Back buttons */ - PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT | PSWIZB_BACK); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + /* Enable the Next and Back buttons */ + PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT | PSWIZB_BACK); + break; - case PSN_WIZNEXT: - /* Handle a Next button click, if necessary */ - if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SEARCHHERE)) - { - SaveCustomPath(GetDlgItem(hwndDlg, IDC_COMBO_PATH)); - HeapFree(GetProcessHeap(), 0, DevInstData->CustomSearchPath); - DevInstData->CustomSearchPath = NULL; - if (PrepareFoldersToScan( - DevInstData, - IsDlgButtonChecked(hwndDlg, IDC_CHECK_MEDIA), - IsDlgButtonChecked(hwndDlg, IDC_CHECK_PATH), - GetDlgItem(hwndDlg, IDC_COMBO_PATH))) - { - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_SEARCHDRV); - } - else - { - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED); - } - } - else - { - /* FIXME */; - } - return TRUE; + case PSN_WIZNEXT: + /* Handle a Next button click, if necessary */ + if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SEARCHHERE)) + { + SaveCustomPath(GetDlgItem(hwndDlg, IDC_COMBO_PATH)); + HeapFree(GetProcessHeap(), 0, DevInstData->CustomSearchPath); + DevInstData->CustomSearchPath = NULL; + if (PrepareFoldersToScan( + DevInstData, + IsDlgButtonChecked(hwndDlg, IDC_CHECK_MEDIA), + IsDlgButtonChecked(hwndDlg, IDC_CHECK_PATH), + GetDlgItem(hwndDlg, IDC_COMBO_PATH))) + { + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_SEARCHDRV); + } + else + { + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED); + } + } + else + { + /* FIXME */; + } + return TRUE; - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static INT_PTR CALLBACK SearchDrvDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; - DWORD dwThreadId; + PDEVINSTDATA DevInstData; + DWORD dwThreadId; - /* Retrieve pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Retrieve pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - HWND hwndControl; - DWORD dwStyle; + switch (uMsg) + { + case WM_INITDIALOG: + { + HWND hwndControl; + DWORD dwStyle; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - DevInstData->hDialog = hwndDlg; - hwndControl = GetParent(hwndDlg); + DevInstData->hDialog = hwndDlg; + hwndControl = GetParent(hwndDlg); - /* Center the wizard window */ - CenterWindow(hwndControl); + /* Center the wizard window */ + CenterWindow(hwndControl); - SendDlgItemMessage( - hwndDlg, - IDC_DEVICE, - WM_SETTEXT, - 0, - (LPARAM)DevInstData->buffer); + SendDlgItemMessage( + hwndDlg, + IDC_DEVICE, + WM_SETTEXT, + 0, + (LPARAM)DevInstData->buffer); - /* Hide the system menu */ - dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); - SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); - break; - } + /* Hide the system menu */ + dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); + SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); + break; + } - case WM_SEARCH_FINISHED: - { - CloseHandle(hThread); - hThread = 0; - if (wParam == 0) - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_NODRIVER); - else - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLDRV); - break; - } + case WM_SEARCH_FINISHED: + { + CloseHandle(hThread); + hThread = 0; + if (wParam == 0) + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_NODRIVER); + else + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLDRV); + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - PropSheet_SetWizButtons(GetParent(hwndDlg), !PSWIZB_NEXT | !PSWIZB_BACK); - /* Yes, we can safely ignore the problem (if any) */ - SetupDiDestroyDriverInfoList( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - SPDIT_COMPATDRIVER); - hThread = CreateThread(NULL, 0, FindDriverProc, DevInstData, 0, &dwThreadId); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + PropSheet_SetWizButtons(GetParent(hwndDlg), !PSWIZB_NEXT | !PSWIZB_BACK); + /* Yes, we can safely ignore the problem (if any) */ + SetupDiDestroyDriverInfoList( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + SPDIT_COMPATDRIVER); + hThread = CreateThread(NULL, 0, FindDriverProc, DevInstData, 0, &dwThreadId); + break; - case PSN_KILLACTIVE: - if (hThread != 0) - { - SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, TRUE); - return TRUE; - } - break; + case PSN_KILLACTIVE: + if (hThread != 0) + { + SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, TRUE); + return TRUE; + } + break; - case PSN_WIZNEXT: - /* Handle a Next button click, if necessary */ - break; + case PSN_WIZNEXT: + /* Handle a Next button click, if necessary */ + break; - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static INT_PTR CALLBACK InstallDrvDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; - DWORD dwThreadId; + PDEVINSTDATA DevInstData; + DWORD dwThreadId; - /* Retrieve pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Retrieve pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - HWND hwndControl; - DWORD dwStyle; + switch (uMsg) + { + case WM_INITDIALOG: + { + HWND hwndControl; + DWORD dwStyle; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - DevInstData->hDialog = hwndDlg; - hwndControl = GetParent(hwndDlg); + DevInstData->hDialog = hwndDlg; + hwndControl = GetParent(hwndDlg); - /* Center the wizard window */ - CenterWindow(hwndControl); + /* Center the wizard window */ + CenterWindow(hwndControl); - SendDlgItemMessage( - hwndDlg, - IDC_DEVICE, - WM_SETTEXT, - 0, - (LPARAM)DevInstData->drvInfoData.Description); + SendDlgItemMessage( + hwndDlg, + IDC_DEVICE, + WM_SETTEXT, + 0, + (LPARAM)DevInstData->drvInfoData.Description); - /* Hide the system menu */ - dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); - SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); - break; - } + /* Hide the system menu */ + dwStyle = GetWindowLongPtr(hwndControl, GWL_STYLE); + SetWindowLongPtr(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU); + break; + } - case WM_INSTALL_FINISHED: - { - CloseHandle(hThread); - hThread = 0; - if (wParam == 0) - { - /* Should we reboot? */ - SP_DEVINSTALL_PARAMS installParams; - installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); - if (SetupDiGetDeviceInstallParams( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - &installParams)) - { - if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT)) - { - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_NEEDREBOOT); - } - else - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_FINISHPAGE); - break; - } - } - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED); - break; - } + case WM_INSTALL_FINISHED: + { + CloseHandle(hThread); + hThread = 0; + if (wParam == 0) + { + /* Should we reboot? */ + SP_DEVINSTALL_PARAMS installParams; + installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); + if (SetupDiGetDeviceInstallParams( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + &installParams)) + { + if (installParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT)) + { + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_NEEDREBOOT); + } + else + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_FINISHPAGE); + break; + } + } + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_INSTALLFAILED); + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - PropSheet_SetWizButtons(GetParent(hwndDlg), !PSWIZB_NEXT | !PSWIZB_BACK); - hThread = CreateThread(NULL, 0, InstallDriverProc, DevInstData, 0, &dwThreadId); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + PropSheet_SetWizButtons(GetParent(hwndDlg), !PSWIZB_NEXT | !PSWIZB_BACK); + hThread = CreateThread(NULL, 0, InstallDriverProc, DevInstData, 0, &dwThreadId); + break; - case PSN_KILLACTIVE: - if (hThread != 0) - { - SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, TRUE); - return TRUE; - } - break; + case PSN_KILLACTIVE: + if (hThread != 0) + { + SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, TRUE); + return TRUE; + } + break; - case PSN_WIZNEXT: - /* Handle a Next button click, if necessary */ - break; + case PSN_WIZNEXT: + /* Handle a Next button click, if necessary */ + break; - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static INT_PTR CALLBACK NoDriverDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; - HWND hwndControl; + PDEVINSTDATA DevInstData; + HWND hwndControl; - UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(wParam); - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - BOOL DisableableDevice = FALSE; + switch (uMsg) + { + case WM_INITDIALOG: + { + BOOL DisableableDevice = FALSE; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - /* Center the wizard window */ - CenterWindow(GetParent(hwndDlg)); + /* Center the wizard window */ + CenterWindow(GetParent(hwndDlg)); - hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); - ShowWindow(hwndControl, SW_HIDE); - EnableWindow(hwndControl, FALSE); + hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); + ShowWindow(hwndControl, SW_HIDE); + EnableWindow(hwndControl, FALSE); - /* Set title font */ - SendDlgItemMessage( - hwndDlg, - IDC_FINISHTITLE, - WM_SETFONT, - (WPARAM)DevInstData->hTitleFont, - (LPARAM)TRUE); + /* Set title font */ + SendDlgItemMessage( + hwndDlg, + IDC_FINISHTITLE, + WM_SETFONT, + (WPARAM)DevInstData->hTitleFont, + (LPARAM)TRUE); - /* disable the "do not show this dialog anymore" checkbox - if the device cannot be disabled */ - CanDisableDevice( - DevInstData->devInfoData.DevInst, - NULL, - &DisableableDevice); - EnableWindow( - GetDlgItem(hwndDlg, IDC_DONOTSHOWDLG), - DisableableDevice); - break; - } + /* disable the "do not show this dialog anymore" checkbox + if the device cannot be disabled */ + CanDisableDevice( + DevInstData->devInfoData.DevInst, + NULL, + &DisableableDevice); + EnableWindow( + GetDlgItem(hwndDlg, IDC_DONOTSHOWDLG), + DisableableDevice); + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - /* Enable the correct buttons on for the active page */ - PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + /* Enable the correct buttons on for the active page */ + PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH); + break; - case PSN_WIZBACK: - /* Handle a Back button click, if necessary */ - hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); - ShowWindow(hwndControl, SW_SHOW); - EnableWindow(hwndControl, TRUE); - PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_CHSOURCE); - return TRUE; + case PSN_WIZBACK: + /* Handle a Back button click, if necessary */ + hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); + ShowWindow(hwndControl, SW_SHOW); + EnableWindow(hwndControl, TRUE); + PropSheet_SetCurSelByID(GetParent(hwndDlg), IDD_CHSOURCE); + return TRUE; - case PSN_WIZFINISH: - { - BOOL DisableableDevice = FALSE; - BOOL IsStarted = FALSE; + case PSN_WIZFINISH: + { + BOOL DisableableDevice = FALSE; + BOOL IsStarted = FALSE; - if (CanDisableDevice(DevInstData->devInfoData.DevInst, - NULL, - &DisableableDevice) && - DisableableDevice && - IsDeviceStarted( - DevInstData->devInfoData.DevInst, - NULL, - &IsStarted) && - !IsStarted && - SendDlgItemMessage( - hwndDlg, - IDC_DONOTSHOWDLG, - BM_GETCHECK, - (WPARAM)0, (LPARAM)0) == BST_CHECKED) - { - /* disable the device */ - StartDevice( - DevInstData->hDevInfo, - &DevInstData->devInfoData, - FALSE, - 0, - NULL); - } - break; - } + if (CanDisableDevice(DevInstData->devInfoData.DevInst, + NULL, + &DisableableDevice) && + DisableableDevice && + IsDeviceStarted( + DevInstData->devInfoData.DevInst, + NULL, + &IsStarted) && + !IsStarted && + SendDlgItemMessage( + hwndDlg, + IDC_DONOTSHOWDLG, + BM_GETCHECK, + (WPARAM)0, (LPARAM)0) == BST_CHECKED) + { + /* disable the device */ + StartDevice( + DevInstData->hDevInfo, + &DevInstData->devInfoData, + FALSE, + 0, + NULL); + } + break; + } - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static INT_PTR CALLBACK InstallFailedDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; - UNREFERENCED_PARAMETER(wParam); + PDEVINSTDATA DevInstData; + UNREFERENCED_PARAMETER(wParam); - /* Retrieve pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Retrieve pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - HWND hwndControl; + switch (uMsg) + { + case WM_INITDIALOG: + { + HWND hwndControl; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - /* Center the wizard window */ - CenterWindow(GetParent(hwndDlg)); + /* Center the wizard window */ + CenterWindow(GetParent(hwndDlg)); - hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); - ShowWindow(hwndControl, SW_HIDE); - EnableWindow(hwndControl, FALSE); + hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); + ShowWindow(hwndControl, SW_HIDE); + EnableWindow(hwndControl, FALSE); - SendDlgItemMessage( - hwndDlg, - IDC_DEVICE, - WM_SETTEXT, - 0, - (LPARAM)DevInstData->drvInfoData.Description); + SendDlgItemMessage( + hwndDlg, + IDC_DEVICE, + WM_SETTEXT, + 0, + (LPARAM)DevInstData->drvInfoData.Description); - /* Set title font */ - SendDlgItemMessage( - hwndDlg, - IDC_FINISHTITLE, - WM_SETFONT, - (WPARAM)DevInstData->hTitleFont, - (LPARAM)TRUE); - break; - } + /* Set title font */ + SendDlgItemMessage( + hwndDlg, + IDC_FINISHTITLE, + WM_SETFONT, + (WPARAM)DevInstData->hTitleFont, + (LPARAM)TRUE); + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - /* Enable the correct buttons on for the active page */ - PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + /* Enable the correct buttons on for the active page */ + PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH); + break; - case PSN_WIZBACK: - /* Handle a Back button click, if necessary */ - break; + case PSN_WIZBACK: + /* Handle a Back button click, if necessary */ + break; - case PSN_WIZFINISH: - /* Handle a Finish button click, if necessary */ - break; + case PSN_WIZFINISH: + /* Handle a Finish button click, if necessary */ + break; - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static INT_PTR CALLBACK NeedRebootDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; - UNREFERENCED_PARAMETER(wParam); + PDEVINSTDATA DevInstData; + UNREFERENCED_PARAMETER(wParam); - /* Retrieve pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Retrieve pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - HWND hwndControl; + switch (uMsg) + { + case WM_INITDIALOG: + { + HWND hwndControl; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - /* Center the wizard window */ - CenterWindow(GetParent(hwndDlg)); + /* Center the wizard window */ + CenterWindow(GetParent(hwndDlg)); - hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); - ShowWindow(hwndControl, SW_HIDE); - EnableWindow(hwndControl, FALSE); + hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); + ShowWindow(hwndControl, SW_HIDE); + EnableWindow(hwndControl, FALSE); - SendDlgItemMessage( - hwndDlg, - IDC_DEVICE, - WM_SETTEXT, - 0, - (LPARAM)DevInstData->drvInfoData.Description); + SendDlgItemMessage( + hwndDlg, + IDC_DEVICE, + WM_SETTEXT, + 0, + (LPARAM)DevInstData->drvInfoData.Description); - /* Set title font */ - SendDlgItemMessage( - hwndDlg, - IDC_FINISHTITLE, - WM_SETFONT, - (WPARAM)DevInstData->hTitleFont, - (LPARAM)TRUE); - break; - } + /* Set title font */ + SendDlgItemMessage( + hwndDlg, + IDC_FINISHTITLE, + WM_SETFONT, + (WPARAM)DevInstData->hTitleFont, + (LPARAM)TRUE); + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - /* Enable the correct buttons on for the active page */ - PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + /* Enable the correct buttons on for the active page */ + PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH); + break; - case PSN_WIZBACK: - /* Handle a Back button click, if necessary */ - break; + case PSN_WIZBACK: + /* Handle a Back button click, if necessary */ + break; - case PSN_WIZFINISH: - /* Handle a Finish button click, if necessary */ - break; + case PSN_WIZFINISH: + /* Handle a Finish button click, if necessary */ + break; - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static INT_PTR CALLBACK FinishDlgProc( - IN HWND hwndDlg, - IN UINT uMsg, - IN WPARAM wParam, - IN LPARAM lParam) + IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) { - PDEVINSTDATA DevInstData; - UNREFERENCED_PARAMETER(wParam); + PDEVINSTDATA DevInstData; + UNREFERENCED_PARAMETER(wParam); - /* Retrieve pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); + /* Retrieve pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)GetWindowLongPtr(hwndDlg, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - HWND hwndControl; + switch (uMsg) + { + case WM_INITDIALOG: + { + HWND hwndControl; - /* Get pointer to the global setup data */ - DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; - SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); + /* Get pointer to the global setup data */ + DevInstData = (PDEVINSTDATA)((LPPROPSHEETPAGE)lParam)->lParam; + SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)DevInstData); - /* Center the wizard window */ - CenterWindow(GetParent(hwndDlg)); + /* Center the wizard window */ + CenterWindow(GetParent(hwndDlg)); - hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); - ShowWindow(hwndControl, SW_HIDE); - EnableWindow(hwndControl, FALSE); + hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL); + ShowWindow(hwndControl, SW_HIDE); + EnableWindow(hwndControl, FALSE); - SendDlgItemMessage( - hwndDlg, - IDC_DEVICE, - WM_SETTEXT, - 0, - (LPARAM)DevInstData->drvInfoData.Description); + SendDlgItemMessage( + hwndDlg, + IDC_DEVICE, + WM_SETTEXT, + 0, + (LPARAM)DevInstData->drvInfoData.Description); - /* Set title font */ - SendDlgItemMessage( - hwndDlg, - IDC_FINISHTITLE, - WM_SETFONT, - (WPARAM)DevInstData->hTitleFont, - (LPARAM)TRUE); - break; - } + /* Set title font */ + SendDlgItemMessage( + hwndDlg, + IDC_FINISHTITLE, + WM_SETFONT, + (WPARAM)DevInstData->hTitleFont, + (LPARAM)TRUE); + break; + } - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; + case WM_NOTIFY: + { + LPNMHDR lpnm = (LPNMHDR)lParam; - switch (lpnm->code) - { - case PSN_SETACTIVE: - /* Enable the correct buttons on for the active page */ - PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH); - break; + switch (lpnm->code) + { + case PSN_SETACTIVE: + /* Enable the correct buttons on for the active page */ + PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH); + break; - case PSN_WIZBACK: - /* Handle a Back button click, if necessary */ - break; + case PSN_WIZBACK: + /* Handle a Back button click, if necessary */ + break; - case PSN_WIZFINISH: - /* Handle a Finish button click, if necessary */ - break; + case PSN_WIZFINISH: + /* Handle a Finish button click, if necessary */ + break; - default: - break; - } - break; - } + default: + break; + } + break; + } - default: - break; - } + default: + break; + } - return FALSE; + return FALSE; } static HFONT CreateTitleFont(VOID) { - NONCLIENTMETRICSW ncm; - LOGFONTW LogFont; - HDC hdc; - INT FontSize; - HFONT hFont; + NONCLIENTMETRICSW ncm; + LOGFONTW LogFont; + HDC hdc; + INT FontSize; + HFONT hFont; - ncm.cbSize = sizeof(NONCLIENTMETRICSW); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); + ncm.cbSize = sizeof(NONCLIENTMETRICSW); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); - LogFont = ncm.lfMessageFont; - LogFont.lfWeight = FW_BOLD; - wcscpy(LogFont.lfFaceName, L"MS Shell Dlg"); + LogFont = ncm.lfMessageFont; + LogFont.lfWeight = FW_BOLD; + wcscpy(LogFont.lfFaceName, L"MS Shell Dlg"); - hdc = GetDC(NULL); - FontSize = 12; - LogFont.lfHeight = 0 - GetDeviceCaps (hdc, LOGPIXELSY) * FontSize / 72; - hFont = CreateFontIndirectW(&LogFont); - ReleaseDC(NULL, hdc); + hdc = GetDC(NULL); + FontSize = 12; + LogFont.lfHeight = 0 - GetDeviceCaps (hdc, LOGPIXELSY) * FontSize / 72; + hFont = CreateFontIndirectW(&LogFont); + ReleaseDC(NULL, hdc); - return hFont; + return hFont; } BOOL DisplayWizard( - IN PDEVINSTDATA DevInstData, - IN HWND hwndParent, - IN UINT startPage) + IN PDEVINSTDATA DevInstData, + IN HWND hwndParent, + IN UINT startPage) { - PROPSHEETHEADER psh; - HPROPSHEETPAGE ahpsp[IDD_MAXIMUMPAGE + 1]; - PROPSHEETPAGE psp; + PROPSHEETHEADER psh; + HPROPSHEETPAGE ahpsp[IDD_MAXIMUMPAGE + 1]; + PROPSHEETPAGE psp; - /* Create the Welcome page */ - ZeroMemory(&psp, sizeof(PROPSHEETPAGE)); - psp.dwSize = sizeof(PROPSHEETPAGE); - psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; - psp.hInstance = hDllInstance; - psp.lParam = (LPARAM)DevInstData; - psp.pfnDlgProc = (DLGPROC) WelcomeDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_WELCOMEPAGE); - ahpsp[IDD_WELCOMEPAGE] = CreatePropertySheetPage(&psp); + /* Create the Welcome page */ + ZeroMemory(&psp, sizeof(PROPSHEETPAGE)); + psp.dwSize = sizeof(PROPSHEETPAGE); + psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; + psp.hInstance = hDllInstance; + psp.lParam = (LPARAM)DevInstData; + psp.pfnDlgProc = (DLGPROC) WelcomeDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_WELCOMEPAGE); + ahpsp[IDD_WELCOMEPAGE] = CreatePropertySheetPage(&psp); - /* Create the Select Source page */ - psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; - psp.pfnDlgProc = (DLGPROC) CHSourceDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_CHSOURCE); - ahpsp[IDD_CHSOURCE] = CreatePropertySheetPage(&psp); + /* Create the Select Source page */ + psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + psp.pfnDlgProc = (DLGPROC) CHSourceDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_CHSOURCE); + ahpsp[IDD_CHSOURCE] = CreatePropertySheetPage(&psp); - /* Create the Search driver page */ - psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; - psp.pfnDlgProc = (DLGPROC) SearchDrvDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_SEARCHDRV); - ahpsp[IDD_SEARCHDRV] = CreatePropertySheetPage(&psp); + /* Create the Search driver page */ + psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + psp.pfnDlgProc = (DLGPROC) SearchDrvDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_SEARCHDRV); + ahpsp[IDD_SEARCHDRV] = CreatePropertySheetPage(&psp); - /* Create the Install driver page */ - psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; - psp.pfnDlgProc = (DLGPROC) InstallDrvDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_INSTALLDRV); - ahpsp[IDD_INSTALLDRV] = CreatePropertySheetPage(&psp); + /* Create the Install driver page */ + psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE; + psp.pfnDlgProc = (DLGPROC) InstallDrvDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_INSTALLDRV); + ahpsp[IDD_INSTALLDRV] = CreatePropertySheetPage(&psp); - /* Create the No driver page */ - psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; - psp.pfnDlgProc = (DLGPROC) NoDriverDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_NODRIVER); - ahpsp[IDD_NODRIVER] = CreatePropertySheetPage(&psp); + /* Create the No driver page */ + psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; + psp.pfnDlgProc = (DLGPROC) NoDriverDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_NODRIVER); + ahpsp[IDD_NODRIVER] = CreatePropertySheetPage(&psp); - /* Create the Install failed page */ - psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; - psp.pfnDlgProc = (DLGPROC) InstallFailedDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_INSTALLFAILED); - ahpsp[IDD_INSTALLFAILED] = CreatePropertySheetPage(&psp); + /* Create the Install failed page */ + psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; + psp.pfnDlgProc = (DLGPROC) InstallFailedDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_INSTALLFAILED); + ahpsp[IDD_INSTALLFAILED] = CreatePropertySheetPage(&psp); - /* Create the Need reboot page */ - psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; - psp.pfnDlgProc = (DLGPROC) NeedRebootDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_NEEDREBOOT); - ahpsp[IDD_NEEDREBOOT] = CreatePropertySheetPage(&psp); + /* Create the Need reboot page */ + psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; + psp.pfnDlgProc = (DLGPROC) NeedRebootDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_NEEDREBOOT); + ahpsp[IDD_NEEDREBOOT] = CreatePropertySheetPage(&psp); - /* Create the Finish page */ - psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; - psp.pfnDlgProc = (DLGPROC) FinishDlgProc; - psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHPAGE); - ahpsp[IDD_FINISHPAGE] = CreatePropertySheetPage(&psp); + /* Create the Finish page */ + psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; + psp.pfnDlgProc = (DLGPROC) FinishDlgProc; + psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHPAGE); + ahpsp[IDD_FINISHPAGE] = CreatePropertySheetPage(&psp); - /* Create the property sheet */ - psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER; - psh.hInstance = hDllInstance; - psh.hwndParent = hwndParent; - psh.nPages = IDD_MAXIMUMPAGE + 1; - psh.nStartPage = startPage; - psh.phpage = ahpsp; - psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK); - psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER); + /* Create the property sheet */ + psh.dwSize = sizeof(PROPSHEETHEADER); + psh.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER; + psh.hInstance = hDllInstance; + psh.hwndParent = hwndParent; + psh.nPages = IDD_MAXIMUMPAGE + 1; + psh.nStartPage = startPage; + psh.phpage = ahpsp; + psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK); + psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER); - /* Create title font */ - DevInstData->hTitleFont = CreateTitleFont(); + /* Create title font */ + DevInstData->hTitleFont = CreateTitleFont(); - /* Display the wizard */ - PropertySheet(&psh); + /* Display the wizard */ + PropertySheet(&psh); - DeleteObject(DevInstData->hTitleFont); + DeleteObject(DevInstData->hTitleFont); - return TRUE; + return TRUE; }