Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

772 lines
24 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation
  6. //
  7. // File: intro.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "newdevp.h"
  11. #include <dbt.h>
  12. INT_PTR
  13. InitIntroDlgProc(
  14. HWND hDlg,
  15. PNEWDEVWIZ NewDevWiz
  16. )
  17. {
  18. HFONT hfont;
  19. HDC hDC;
  20. int FontSize, PtsPixels;
  21. LOGFONT LogFont;
  22. //
  23. // Create the big bold font
  24. //
  25. hDC = GetDC(hDlg);
  26. if (hDC) {
  27. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG1), WM_GETFONT, 0, 0);
  28. GetObject(hfont, sizeof(LogFont), &LogFont);
  29. LogFont.lfWeight = FW_BOLD;
  30. PtsPixels = GetDeviceCaps(hDC, LOGPIXELSY);
  31. FontSize = 12;
  32. LogFont.lfHeight = 0 - (PtsPixels * FontSize / 72);
  33. NewDevWiz->hfontTextBigBold = CreateFontIndirect(&LogFont);
  34. if (NewDevWiz->hfontTextBigBold ) {
  35. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG1), NewDevWiz->hfontTextBigBold, TRUE);
  36. }
  37. }
  38. //
  39. // Create the bold font
  40. //
  41. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG3), WM_GETFONT, 0, 0);
  42. GetObject(hfont, sizeof(LogFont), &LogFont);
  43. LogFont.lfWeight = FW_BOLD;
  44. NewDevWiz->hfontTextBold = CreateFontIndirect(&LogFont);
  45. if (NewDevWiz->hfontTextBold ) {
  46. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG3), NewDevWiz->hfontTextBold, TRUE);
  47. }
  48. if (NDWTYPE_UPDATE == NewDevWiz->InstallType) {
  49. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_UPGRADE, IDS_INTRO_MSG1_UPGRADE);
  50. } else {
  51. //
  52. // The default text on the Wizard is for the Found New Hardware case, so we only
  53. // need to set the title text.
  54. //
  55. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_NEW, IDS_INTRO_MSG1_NEW);
  56. }
  57. //
  58. // Set the Initial radio button state to do auto-search.
  59. //
  60. CheckRadioButton(hDlg,
  61. IDC_INTRO_SEARCH,
  62. IDC_INTRO_ADVANCED,
  63. IDC_INTRO_SEARCH
  64. );
  65. return TRUE;
  66. }
  67. INT_PTR CALLBACK
  68. IntroDlgProc(
  69. HWND hDlg,
  70. UINT wMsg,
  71. WPARAM wParam,
  72. LPARAM lParam
  73. )
  74. {
  75. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  76. if (wMsg == WM_INITDIALOG) {
  77. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  78. NewDevWiz = (PNEWDEVWIZ)lppsp->lParam;
  79. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  80. if (!InitIntroDlgProc(hDlg, NewDevWiz)) {
  81. return FALSE;
  82. }
  83. return TRUE;
  84. }
  85. switch (wMsg) {
  86. case WM_DESTROY: {
  87. if (NewDevWiz->hfontTextBigBold ) {
  88. DeleteObject(NewDevWiz->hfontTextBigBold);
  89. NewDevWiz->hfontTextBigBold = NULL;
  90. }
  91. if (NewDevWiz->hfontTextBold ) {
  92. DeleteObject(NewDevWiz->hfontTextBold);
  93. NewDevWiz->hfontTextBold = NULL;
  94. }
  95. break;
  96. }
  97. case WM_NOTIFY:
  98. switch (((NMHDR FAR *)lParam)->code) {
  99. case PSN_SETACTIVE:
  100. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
  101. NewDevWiz->PrevPage = IDD_NEWDEVWIZ_INTRO;
  102. SetDriverDescription(hDlg, IDC_INTRO_DRVDESC, NewDevWiz);
  103. if (NewDevWiz->InstallType == NDWTYPE_FOUNDNEW) {
  104. SetTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID, INSTALL_COMPLETE_CHECK_TIMEOUT, NULL);
  105. }
  106. break;
  107. case PSN_RESET:
  108. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  109. break;
  110. case PSN_WIZNEXT:
  111. NewDevWiz->EnterFrom = IDD_NEWDEVWIZ_INTRO;
  112. if (IsDlgButtonChecked(hDlg, IDC_INTRO_SEARCH)) {
  113. //
  114. // Set the search flags to search the following places automatically:
  115. // - default INF search path
  116. // - Windows Update, if we are connected to the Internet
  117. // - CD-ROM drives
  118. // - Floppy drives
  119. //
  120. NewDevWiz->SearchOptions = (SEARCH_CURRENTDRIVER |
  121. SEARCH_DEFAULT |
  122. SEARCH_FLOPPY |
  123. SEARCH_CDROM |
  124. SEARCH_INET_IF_CONNECTED
  125. );
  126. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SEARCHING);
  127. } else {
  128. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_ADVANCEDSEARCH);
  129. }
  130. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  131. break;
  132. }
  133. break;
  134. case WM_DEVICECHANGE:
  135. if ((wParam == DBT_DEVICEARRIVAL) &&
  136. (((PDEV_BROADCAST_VOLUME)lParam)->dbcv_devicetype == DBT_DEVTYP_VOLUME) &&
  137. (((PDEV_BROADCAST_VOLUME)lParam)->dbcv_flags & DBTF_MEDIA) &&
  138. (IsDlgButtonChecked(hDlg, IDC_INTRO_SEARCH))) {
  139. PropSheet_PressButton(GetParent(hDlg), PSBTN_NEXT);
  140. }
  141. break;
  142. case WM_TIMER:
  143. if (INSTALL_COMPLETE_CHECK_TIMERID == wParam) {
  144. if (IsInstallComplete(NewDevWiz->hDeviceInfo, &NewDevWiz->DeviceInfoData)) {
  145. PropSheet_PressButton(GetParent(hDlg), PSBTN_CANCEL);
  146. }
  147. }
  148. break;
  149. default:
  150. return(FALSE);
  151. }
  152. return(TRUE);
  153. }
  154. INT_PTR
  155. FinishInstallInitIntroDlgProc(
  156. HWND hDlg,
  157. PNEWDEVWIZ NewDevWiz
  158. )
  159. {
  160. HFONT hfont;
  161. HDC hDC;
  162. int FontSize, PtsPixels;
  163. LOGFONT LogFont;
  164. //
  165. // Create the big bold font
  166. //
  167. hDC = GetDC(hDlg);
  168. if (hDC) {
  169. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG1), WM_GETFONT, 0, 0);
  170. GetObject(hfont, sizeof(LogFont), &LogFont);
  171. LogFont.lfWeight = FW_BOLD;
  172. PtsPixels = GetDeviceCaps(hDC, LOGPIXELSY);
  173. FontSize = 12;
  174. LogFont.lfHeight = 0 - (PtsPixels * FontSize / 72);
  175. NewDevWiz->hfontTextBigBold = CreateFontIndirect(&LogFont);
  176. if (NewDevWiz->hfontTextBigBold ) {
  177. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG1), NewDevWiz->hfontTextBigBold, TRUE);
  178. }
  179. }
  180. //
  181. // Create the bold font
  182. //
  183. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG3), WM_GETFONT, 0, 0);
  184. GetObject(hfont, sizeof(LogFont), &LogFont);
  185. LogFont.lfWeight = FW_BOLD;
  186. NewDevWiz->hfontTextBold = CreateFontIndirect(&LogFont);
  187. if (NewDevWiz->hfontTextBold ) {
  188. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG3), NewDevWiz->hfontTextBold, TRUE);
  189. }
  190. if (NDWTYPE_UPDATE == NewDevWiz->InstallType) {
  191. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_UPGRADE, IDS_INTRO_MSG1_UPGRADE);
  192. } else {
  193. //
  194. // The default text on the Wizard is for the Found New Hardware case, so we only
  195. // need to set the title text.
  196. //
  197. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_NEW, IDS_INTRO_MSG1_NEW);
  198. }
  199. return TRUE;
  200. }
  201. INT_PTR CALLBACK
  202. FinishInstallIntroDlgProc(
  203. HWND hDlg,
  204. UINT wMsg,
  205. WPARAM wParam,
  206. LPARAM lParam
  207. )
  208. {
  209. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  210. HICON hicon;
  211. UNREFERENCED_PARAMETER(wParam);
  212. if (wMsg == WM_INITDIALOG) {
  213. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  214. NewDevWiz = (PNEWDEVWIZ)lppsp->lParam;
  215. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  216. if (!InitIntroDlgProc(hDlg, NewDevWiz)) {
  217. return FALSE;
  218. }
  219. return TRUE;
  220. }
  221. switch (wMsg) {
  222. case WM_DESTROY: {
  223. if (NewDevWiz->hfontTextBigBold ) {
  224. DeleteObject(NewDevWiz->hfontTextBigBold);
  225. NewDevWiz->hfontTextBigBold = NULL;
  226. }
  227. if (NewDevWiz->hfontTextBold ) {
  228. DeleteObject(NewDevWiz->hfontTextBold);
  229. NewDevWiz->hfontTextBold = NULL;
  230. }
  231. hicon = (HICON)SendDlgItemMessage(hDlg, IDC_CLASSICON, STM_GETICON, 0, 0);
  232. if (hicon) {
  233. DestroyIcon(hicon);
  234. }
  235. break;
  236. }
  237. case WM_NOTIFY:
  238. switch (((NMHDR FAR *)lParam)->code) {
  239. case PSN_SETACTIVE:
  240. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
  241. NewDevWiz->PrevPage = IDD_NEWDEVWIZ_INTRO;
  242. SetDriverDescription(hDlg, IDC_INTRO_DRVDESC, NewDevWiz);
  243. if (SetupDiLoadClassIcon(NewDevWiz->ClassGuidSelected, &hicon, NULL)) {
  244. hicon = (HICON)SendDlgItemMessage(hDlg, IDC_CLASSICON, STM_SETICON, (WPARAM)hicon, 0L);
  245. if (hicon) {
  246. DestroyIcon(hicon);
  247. }
  248. }
  249. //
  250. // We also need to set the title for the wizard since we are the first wizard
  251. // page.
  252. //
  253. PropSheet_SetTitle(GetParent(hDlg),
  254. 0,
  255. (NewDevWiz->InstallType == NDWTYPE_FOUNDNEW) ?
  256. MAKEINTRESOURCE(IDS_FOUNDDEVICE) :
  257. MAKEINTRESOURCE(IDS_UPDATEDEVICE)
  258. );
  259. break;
  260. case PSN_RESET:
  261. break;
  262. case PSN_WIZNEXT:
  263. break;
  264. }
  265. break;
  266. default:
  267. return(FALSE);
  268. }
  269. return(TRUE);
  270. }
  271. int CALLBACK
  272. BrowseCallbackProc(
  273. HWND hwnd,
  274. UINT uMsg,
  275. LPARAM lParam,
  276. LPARAM lpData
  277. )
  278. {
  279. switch (uMsg) {
  280. case BFFM_INITIALIZED:
  281. SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, lpData);
  282. break;
  283. case BFFM_SELCHANGED: {
  284. TCHAR CurrentPath[MAX_PATH];
  285. if (lParam &&
  286. SHGetPathFromIDList((LPITEMIDLIST)lParam, CurrentPath) &&
  287. pSetupConcatenatePaths(CurrentPath, TEXT("*.INF"), MAX_PATH, NULL)) {
  288. SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)FileExists(CurrentPath, NULL));
  289. } else {
  290. //
  291. // We couldn't get the directory path from shell, or the directory
  292. // won't fit into our CurrentPath buffer, so gray out the OK
  293. // button since the directory isn't valid.
  294. //
  295. SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)FALSE);
  296. }
  297. break;
  298. }
  299. default:
  300. break;
  301. }
  302. return 0;
  303. }
  304. VOID
  305. DoBrowse(
  306. HWND hDlg
  307. )
  308. {
  309. BROWSEINFO bi;
  310. TCHAR CurrentLocation[MAX_PATH];
  311. TCHAR Title[MAX_PATH];
  312. LPITEMIDLIST pidl;
  313. ZeroMemory(&bi, sizeof(bi));
  314. //
  315. // Get the current directory path in the location combo control to pass to
  316. // the browse API so it can use that as it's starting point. If there is
  317. // too much text in the locaion combo then just pass in the empty string
  318. // as the starting point to the browse control.
  319. //
  320. if (GetWindowTextLength(GetWindow(hDlg, IDC_ADVANCED_LOCATION_COMBO)) < SIZECHARS(CurrentLocation)) {
  321. GetDlgItemText(hDlg,
  322. IDC_ADVANCED_LOCATION_COMBO,
  323. CurrentLocation,
  324. SIZECHARS(CurrentLocation)
  325. );
  326. } else {
  327. StringCchCopy(CurrentLocation, SIZECHARS(CurrentLocation), TEXT(""));
  328. }
  329. if (!LoadString(hNewDev, IDS_BROWSE_TITLE, Title, SIZECHARS(Title))) {
  330. Title[0] = TEXT('0');
  331. }
  332. bi.hwndOwner = hDlg;
  333. bi.pidlRoot = NULL;
  334. bi.pszDisplayName = NULL;
  335. bi.lpszTitle = Title;
  336. bi.ulFlags = BIF_NEWDIALOGSTYLE |
  337. BIF_RETURNONLYFSDIRS |
  338. BIF_RETURNFSANCESTORS |
  339. BIF_STATUSTEXT |
  340. BIF_NONEWFOLDERBUTTON |
  341. BIF_UAHINT;
  342. bi.lpfn = BrowseCallbackProc;
  343. bi.lParam = (LPARAM)CurrentLocation;
  344. pidl = SHBrowseForFolder(&bi);
  345. if (pidl && SHGetPathFromIDList(pidl, CurrentLocation)) {
  346. SetDlgItemText(hDlg,
  347. IDC_ADVANCED_LOCATION_COMBO,
  348. CurrentLocation
  349. );
  350. }
  351. }
  352. INT_PTR
  353. InitAdvancedSearchDlgProc(
  354. HWND hDlg
  355. )
  356. {
  357. PTSTR *PathList;
  358. UINT PathCount;
  359. INT i;
  360. DWORD SearchOptions;
  361. //
  362. // Set the Initial radio button state to do auto-search.
  363. //
  364. CheckRadioButton(hDlg,
  365. IDC_ADVANCED_SEARCH,
  366. IDC_ADVANCED_LIST,
  367. IDC_ADVANCED_SEARCH
  368. );
  369. SearchOptions = GetSearchOptions();
  370. if ((SearchOptions & SEARCH_FLOPPY) ||
  371. (SearchOptions & SEARCH_CDROM)) {
  372. CheckDlgButton(hDlg, IDC_ADVANCED_REMOVABLEMEDIA, BST_CHECKED);
  373. }
  374. if (SearchOptions & SEARCH_DIRECTORY) {
  375. CheckDlgButton(hDlg, IDC_ADVANCED_LOCATION, BST_CHECKED);
  376. }
  377. //
  378. // Fill in the paths in the combo box
  379. //
  380. if (SetupQuerySourceList(0, &PathList, &PathCount)) {
  381. for (i=0; i<(int)PathCount; i++) {
  382. SendMessage(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO),
  383. CB_ADDSTRING,
  384. 0,
  385. (LPARAM)PathList[i]
  386. );
  387. }
  388. SetupFreeSourceList(&PathList, PathCount);
  389. }
  390. //
  391. // Disable the search combo box and browse button by default.
  392. //
  393. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), (SearchOptions & SEARCH_DIRECTORY));
  394. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE), (SearchOptions & SEARCH_DIRECTORY));
  395. //
  396. // Limit the text in the edit control to MAX_PATH characters, select
  397. // the first item and set up the autocomplet for directories.
  398. //
  399. SendMessage(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), CB_LIMITTEXT, MAX_PATH, 0);
  400. SendMessage(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), CB_SETCURSEL, 0, 0);
  401. SHAutoComplete(GetWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), GW_CHILD), SHACF_FILESYS_DIRS);
  402. return TRUE;
  403. }
  404. INT_PTR CALLBACK
  405. AdvancedSearchDlgProc(
  406. HWND hDlg,
  407. UINT wMsg,
  408. WPARAM wParam,
  409. LPARAM lParam
  410. )
  411. {
  412. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  413. if (wMsg == WM_INITDIALOG) {
  414. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  415. NewDevWiz = (PNEWDEVWIZ)lppsp->lParam;
  416. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  417. if (!InitAdvancedSearchDlgProc(hDlg)) {
  418. return FALSE;
  419. }
  420. return TRUE;
  421. }
  422. switch (wMsg) {
  423. case WM_COMMAND:
  424. switch (LOWORD(wParam)) {
  425. case IDC_ADVANCED_SEARCH:
  426. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_REMOVABLEMEDIA), TRUE);
  427. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION), TRUE);
  428. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO),
  429. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  430. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE),
  431. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  432. break;
  433. case IDC_ADVANCED_LIST:
  434. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_REMOVABLEMEDIA), FALSE);
  435. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION), FALSE);
  436. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), FALSE);
  437. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE), FALSE);
  438. break;
  439. case IDC_ADVANCED_LOCATION:
  440. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO),
  441. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  442. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE),
  443. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  444. break;
  445. case IDC_BROWSE:
  446. if (HIWORD(wParam) == BN_CLICKED) {
  447. DoBrowse(hDlg);
  448. }
  449. }
  450. break;
  451. case WM_NOTIFY:
  452. switch (((NMHDR FAR *)lParam)->code) {
  453. case PSN_SETACTIVE:
  454. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  455. NewDevWiz->PrevPage = IDD_NEWDEVWIZ_ADVANCEDSEARCH;
  456. if (NewDevWiz->InstallType == NDWTYPE_FOUNDNEW) {
  457. SetTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID, INSTALL_COMPLETE_CHECK_TIMEOUT, NULL);
  458. }
  459. break;
  460. case PSN_RESET:
  461. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  462. break;
  463. case PSN_WIZNEXT:
  464. NewDevWiz->EnterFrom = IDD_NEWDEVWIZ_ADVANCEDSEARCH;
  465. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  466. if (IsDlgButtonChecked(hDlg, IDC_ADVANCED_SEARCH)) {
  467. NewDevWiz->SearchOptions = SEARCH_CURRENTDRIVER |
  468. SEARCH_DEFAULT |
  469. SEARCH_INET_IF_CONNECTED;
  470. if (IsDlgButtonChecked(hDlg, IDC_ADVANCED_REMOVABLEMEDIA)) {
  471. NewDevWiz->SearchOptions |= (SEARCH_FLOPPY | SEARCH_CDROM);
  472. }
  473. if (IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION)) {
  474. TCHAR TempPath[MAX_PATH];
  475. TCHAR MessageTitle[MAX_PATH];
  476. TCHAR MessageText[MAX_PATH*2];
  477. BOOL bPathIsGood = TRUE;
  478. if ((GetWindowTextLength(GetWindow(hDlg, IDC_ADVANCED_LOCATION_COMBO)) < SIZECHARS(NewDevWiz->BrowsePath)) &&
  479. GetDlgItemText(hDlg,
  480. IDC_ADVANCED_LOCATION_COMBO,
  481. NewDevWiz->BrowsePath,
  482. SIZECHARS(NewDevWiz->BrowsePath)
  483. )) {
  484. //
  485. // We have a path, now lets verify it. We will verify
  486. // both the path, and verify that there is at least
  487. // one INF file in that location. If either of these
  488. // aren't true then we will display an warning to the
  489. // user and remain on this page.
  490. //
  491. MessageTitle[0] = TEXT('\0');
  492. MessageText[0] = TEXT('\0');
  493. if (SUCCEEDED(StringCchCopy(TempPath, SIZECHARS(TempPath), NewDevWiz->BrowsePath)) ||
  494. pSetupConcatenatePaths(TempPath, TEXT("*.INF"), MAX_PATH, NULL)) {
  495. //
  496. // We will first check if the path exists at all. To do
  497. // this we need to verify that FindFirstFile fails on
  498. // the directory, and the directory with *.INF
  499. // concatonated on the end. The reason for this is that
  500. // FindFirstFile does not handle root directory paths
  501. // correctly for some reason so they need to be special
  502. // cased.
  503. //
  504. if (!FileExists(NewDevWiz->BrowsePath, NULL) &&
  505. !FileExists(TempPath, NULL)) {
  506. LoadString(hNewDev,
  507. IDS_LOCATION_BAD_DIR,
  508. MessageText,
  509. SIZECHARS(MessageText));
  510. bPathIsGood = FALSE;
  511. } else if (!FileExists(TempPath, NULL)) {
  512. LoadString(hNewDev,
  513. IDS_LOCATION_NO_INFS,
  514. MessageText,
  515. SIZECHARS(MessageText));
  516. bPathIsGood = FALSE;
  517. }
  518. } else {
  519. //
  520. // The user entered too long of a path
  521. //
  522. LoadString(hNewDev,
  523. IDS_LOCATION_BAD_DIR,
  524. MessageText,
  525. SIZECHARS(MessageText));
  526. bPathIsGood = FALSE;
  527. }
  528. if (bPathIsGood) {
  529. SetupAddToSourceList(SRCLIST_SYSIFADMIN, NewDevWiz->BrowsePath);
  530. NewDevWiz->SearchOptions |= SEARCH_DIRECTORY;
  531. } else {
  532. if (GetWindowText(GetParent(hDlg),
  533. MessageTitle,
  534. SIZECHARS(MessageTitle)) &&
  535. (MessageText[0] != TEXT('\0'))) {
  536. MessageBox(hDlg, MessageText, MessageTitle, MB_OK | MB_ICONWARNING);
  537. SetDlgMsgResult(hDlg, wMsg, -1);
  538. break;
  539. }
  540. }
  541. }
  542. }
  543. SetSearchOptions(NewDevWiz->SearchOptions);
  544. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SEARCHING);
  545. } else {
  546. ULONG DevNodeStatus;
  547. ULONG Problem=0;
  548. SP_DRVINFO_DATA DriverInfoData;
  549. //
  550. // If we have a selected driver,
  551. // or we know the class and there wasn't a problem installing
  552. // go into select device
  553. //
  554. //
  555. DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
  556. if (SetupDiEnumDriverInfo(NewDevWiz->hDeviceInfo,
  557. &NewDevWiz->DeviceInfoData,
  558. SPDIT_COMPATDRIVER,
  559. 0,
  560. &DriverInfoData
  561. )
  562. ||
  563. (!IsEqualGUID(&NewDevWiz->DeviceInfoData.ClassGuid,
  564. &GUID_NULL
  565. )
  566. &&
  567. CM_Get_DevNode_Status(&DevNodeStatus,
  568. &Problem,
  569. NewDevWiz->DeviceInfoData.DevInst,
  570. 0
  571. ) == CR_SUCCESS
  572. &&
  573. Problem != CM_PROB_FAILED_INSTALL
  574. )) {
  575. NewDevWiz->ClassGuidSelected = &NewDevWiz->DeviceInfoData.ClassGuid;
  576. NewDevWiz->EnterInto = IDD_NEWDEVWIZ_SELECTDEVICE;
  577. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SELECTDEVICE);
  578. break;
  579. }
  580. NewDevWiz->ClassGuidSelected = NULL;
  581. NewDevWiz->EnterInto = IDD_NEWDEVWIZ_SELECTCLASS;
  582. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SELECTCLASS);
  583. }
  584. break;
  585. case PSN_WIZBACK:
  586. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  587. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_INTRO);
  588. break;
  589. }
  590. break;
  591. case WM_TIMER:
  592. if (INSTALL_COMPLETE_CHECK_TIMERID == wParam) {
  593. if (IsInstallComplete(NewDevWiz->hDeviceInfo, &NewDevWiz->DeviceInfoData)) {
  594. PropSheet_PressButton(GetParent(hDlg), PSBTN_CANCEL);
  595. }
  596. }
  597. break;
  598. default:
  599. return(FALSE);
  600. }
  601. return(TRUE);
  602. }