Source code of Windows XP (NT5)
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.

821 lines
20 KiB

  1. /*
  2. * repair - Dialog box property sheet for "Repair"
  3. */
  4. #include "tweakui.h"
  5. #pragma BEGIN_CONST_DATA
  6. KL const c_klRegView = { &g_hkCUSMWCV, c_tszRegedit, c_tszView };
  7. const static DWORD CODESEG rgdwHelp[] = {
  8. IDC_REPAIRCOMBO, IDH_REPAIR,
  9. IDC_REPAIRNOW, IDH_REPAIR,
  10. IDC_REPAIRHELP, IDH_REPAIR,
  11. IDC_REPAIRTEXT, IDH_REPAIR,
  12. IDC_REPAIRICON, IDH_REPAIR,
  13. 0, 0,
  14. };
  15. typedef UINT (PASCAL *REPAIRPATHPROC)(HWND hdlg, LPTSTR ptszBuf);
  16. /*****************************************************************************
  17. *
  18. * _Repair_FileFromResource
  19. *
  20. * Given a resource ID and a file name, extract the c_tszExe resource
  21. * into that file.
  22. *
  23. *****************************************************************************/
  24. BOOL PASCAL
  25. _Repair_FileFromResource(UINT idx, LPCTSTR ptszFileName)
  26. {
  27. BOOL fRc;
  28. HRSRC hrsrc = FindResource(hinstCur, (LPCTSTR)IntToPtr(idx), c_tszExe);
  29. if (hrsrc) {
  30. HGLOBAL hglob = LoadResource(hinstCur, hrsrc);
  31. if (hglob) {
  32. PV pv = LockResource(hglob);
  33. if (pv) {
  34. HFILE hf = _lcreat(ptszFileName, 0);
  35. if (hf != HFILE_ERROR) {
  36. UINT cb = SizeofResource(hinstCur, hrsrc);
  37. fRc = _lwrite(hf, (char *)pv, cb) == cb;
  38. _lclose(hf);
  39. if (fRc) {
  40. } else {
  41. DeleteFile(ptszFileName);
  42. }
  43. } else {
  44. fRc = 0;
  45. }
  46. } else {
  47. fRc = 0;
  48. }
  49. } else {
  50. fRc = 0;
  51. }
  52. } else {
  53. fRc = 0;
  54. }
  55. return fRc;
  56. }
  57. /*****************************************************************************
  58. *
  59. * Repair_RunSetupCqn
  60. *
  61. * Put the Setup program into the specified directory and run it.
  62. * WithTempDirectory will clean up the file when we return.
  63. *
  64. *****************************************************************************/
  65. BOOL PASCAL
  66. Repair_RunSetupCqn(LPCTSTR cqn, LPVOID pv)
  67. {
  68. BOOL fRc;
  69. fRc = _Repair_FileFromResource(IDX_SETUP, c_tszSetupExe);
  70. if (fRc) {
  71. STARTUPINFO si;
  72. PROCESS_INFORMATION pi;
  73. ZeroMemory(&si, sizeof(si));
  74. si.cb = sizeof(si);
  75. fRc = CreateProcess(0, c_tszSetupExe, 0, 0, 0, 0, 0, 0, &si, &pi);
  76. if (fRc) {
  77. CloseHandle(pi.hThread);
  78. WaitForSingleObject(pi.hProcess, INFINITE);
  79. CloseHandle(pi.hProcess);
  80. }
  81. }
  82. return fRc;
  83. }
  84. #ifdef _X86_
  85. /*****************************************************************************
  86. *
  87. * Repair_MoveFileExWininit
  88. *
  89. * Rename a file via wininit.ini.
  90. *
  91. *****************************************************************************/
  92. #pragma BEGIN_CONST_DATA
  93. TCHAR c_tszPercentSEqualsPercentS[] = TEXT("%s=%s");
  94. #pragma END_CONST_DATA
  95. void PASCAL
  96. Repair_MoveFileExWininit(LPCTSTR ptszDst, LPCTSTR ptszSrc)
  97. {
  98. TCHAR tszWininit[MAX_PATH];
  99. DWORD cb;
  100. LPSTR pszBuf;
  101. WIN32_FIND_DATA wfd;
  102. HANDLE h;
  103. if (GetWindowsDirectory(tszWininit, cA(tszWininit))) {
  104. lstrcatnBs(tszWininit, c_tszWininit, MAX_PATH);
  105. /* INI files are always in ANSI */
  106. h = FindFirstFile(ptszSrc, &wfd);
  107. if (h != INVALID_HANDLE_VALUE) {
  108. FindClose(h);
  109. } else {
  110. wfd.nFileSizeLow = 0;
  111. }
  112. cb = wfd.nFileSizeLow + MAX_PATH + 1 + MAX_PATH + 3;
  113. pszBuf = (LPSTR)lAlloc(cb);
  114. if (pszBuf) {
  115. LPSTR psz;
  116. if (!GetPrivateProfileSection(c_tszRename, pszBuf, cb, tszWininit)) {
  117. /* No such section; create one */
  118. /* Already done by LocalAlloc (zero-init) */
  119. }
  120. for (psz = pszBuf; psz[0]; psz += lstrlenA(psz) + 1);
  121. psz += wsprintf(psz, c_tszPercentSEqualsPercentS, ptszDst, ptszSrc);
  122. psz[1] = '\0';
  123. WritePrivateProfileSection(c_tszRename, pszBuf, tszWininit);
  124. lFree(pszBuf);
  125. }
  126. }
  127. }
  128. #endif
  129. /*****************************************************************************
  130. *
  131. * Repair_MoveFileEx
  132. *
  133. * Try to rename the file from existing.dll to existing.bak,
  134. * using MoveFileEx or wininit.ini as necessary.
  135. *
  136. * Note that we must use the short name because that's all that
  137. * wininit.ini understands.
  138. *
  139. *****************************************************************************/
  140. void PASCAL
  141. Repair_MoveFileEx(LPTSTR ptszSrc)
  142. {
  143. TCHAR tszDst[MAX_PATH];
  144. GetShortPathName(ptszSrc, ptszSrc, MAX_PATH);
  145. lstrcpy(tszDst, ptszSrc);
  146. lstrcpy(tszDst + lstrlen(tszDst) - 4, c_tszDotBak);
  147. DeleteFile(tszDst);
  148. if (MoveFile(ptszSrc, tszDst)) {
  149. /* All done */
  150. } else if (MoveFileEx(ptszSrc, tszDst, MOVEFILE_DELAY_UNTIL_REBOOT)) {
  151. /* All done */
  152. #ifdef _X86_
  153. } else if (g_fNT) {
  154. /* I did my best */
  155. } else { /* wininit.ini for Windows 95 */
  156. Repair_MoveFileExWininit(tszDst, ptszSrc);
  157. #endif
  158. }
  159. }
  160. /*****************************************************************************
  161. *
  162. * _Repair_RunSetup
  163. *
  164. * Check if there are any hidden DLLs on the desktop.
  165. *
  166. * Extract the tiny little "setup" program attached via our resources,
  167. * run it, delete it, then tell the user they she may need to restart
  168. * the computer for the full effect to kick in.
  169. *
  170. *****************************************************************************/
  171. #pragma BEGIN_CONST_DATA
  172. TCHAR c_tszStarDotDll[] = TEXT("*.DLL");
  173. #pragma END_CONST_DATA
  174. UINT PASCAL
  175. _Repair_RunSetup(HWND hdlg, REPAIRPATHPROC GetRepairPath)
  176. {
  177. PIDL pidl;
  178. if (SUCCEEDED(SHGetSpecialFolderLocation(hdlg, CSIDL_DESKTOPDIRECTORY,
  179. &pidl))) {
  180. HANDLE h;
  181. TCHAR tszDesktop[MAX_PATH];
  182. TCHAR tszSrc[MAX_PATH];
  183. WIN32_FIND_DATA wfd;
  184. SHGetPathFromIDList(pidl, tszDesktop);
  185. lstrcpy(tszSrc, tszDesktop);
  186. lstrcatnBsA(tszSrc, c_tszStarDotDll);
  187. h = FindFirstFile(tszSrc, &wfd);
  188. if (h != INVALID_HANDLE_VALUE) {
  189. do {
  190. lstrcpy(tszSrc, tszDesktop);
  191. lstrcatnBsA(tszSrc, wfd.cFileName);
  192. Repair_MoveFileEx(tszSrc);
  193. } while (FindNextFile(h, &wfd));
  194. FindClose(h);
  195. }
  196. Ole_Free(pidl);
  197. }
  198. WithTempDirectory(Repair_RunSetupCqn, 0);
  199. return IDS_MAYBEREBOOT;
  200. }
  201. /*****************************************************************************
  202. *
  203. * _Repair_GetFontPath
  204. *
  205. * Obtain the path to the Fonts folder.
  206. *
  207. *****************************************************************************/
  208. UINT PASCAL
  209. _Repair_GetFontPath(HWND hdlg, LPTSTR ptszBuf)
  210. {
  211. PIDL pidlFonts;
  212. if (SUCCEEDED(SHGetSpecialFolderLocation(hdlg, CSIDL_FONTS, &pidlFonts))) {
  213. SHGetPathFromIDListA(pidlFonts, ptszBuf);
  214. Ole_Free(pidlFonts);
  215. }
  216. return IDX_FONTFOLDER;
  217. }
  218. /*****************************************************************************
  219. *
  220. * _Repair_GetIEPath
  221. *
  222. * Obtain the path to some IE special folder.
  223. *
  224. * If we can't get it from the registry, then it's just
  225. * "%windir%\ptszSubdir".
  226. *
  227. *****************************************************************************/
  228. void PASCAL
  229. _Repair_GetIEPath(LPTSTR ptszBuf, LPCTSTR ptszKey, LPCTSTR ptszSubdir)
  230. {
  231. HKEY hk;
  232. ptszBuf[0] = TEXT('\0');
  233. if (RegOpenKeyEx(g_hkLMSMWCV, ptszKey, 0, KEY_QUERY_VALUE, &hk)
  234. == ERROR_SUCCESS) {
  235. DWORD cb = cbCtch(MAX_PATH);
  236. DWORD dwType;
  237. RegQueryValueEx(hk, c_tszDirectory, 0, &dwType, (LPBYTE)ptszBuf,
  238. &cb);
  239. RegCloseKey(hk);
  240. if (dwType == REG_EXPAND_SZ) {
  241. LPTSTR ptszTemp;
  242. cb = ExpandEnvironmentStrings(ptszBuf, NULL, 0);
  243. ptszTemp = (LPTSTR)LocalAlloc(LPTR, cb * sizeof(TCHAR));
  244. if (ptszTemp) {
  245. if (ExpandEnvironmentStrings(ptszBuf, ptszTemp, cb)) {
  246. lstrcpyn(ptszBuf, ptszTemp, MAX_PATH);
  247. }
  248. LocalFree(ptszTemp);
  249. }
  250. }
  251. }
  252. if (ptszBuf[0] == TEXT('\0') &&
  253. GetWindowsDirectory(ptszBuf, MAX_PATH - lstrlen(ptszSubdir) - 1)) {
  254. ptszBuf = TweakUi_TrimTrailingBs(ptszBuf);
  255. *ptszBuf++ = TEXT('\\');
  256. lstrcpy(ptszBuf, ptszSubdir);
  257. }
  258. }
  259. /*****************************************************************************
  260. *
  261. * _Repair_GetHistoryPath
  262. *
  263. * Obtain the path to the URL History folder.
  264. *
  265. * If we can't get it from the registry, then it's just
  266. * "%windir%\History".
  267. *
  268. *****************************************************************************/
  269. UINT PASCAL
  270. _Repair_GetHistoryPath(HWND hdlg, LPTSTR ptszBuf)
  271. {
  272. _Repair_GetIEPath(ptszBuf, c_tszUrlHist, c_tszHistory);
  273. return IDX_HISTORY;
  274. }
  275. /*****************************************************************************
  276. *
  277. * _Repair_GetCachePath
  278. *
  279. * Obtain the path to the Temporary Internet Files folder.
  280. *
  281. * If we can't get it from the registry, then it's just
  282. * "%windir%\Temporary Internet Files".
  283. *
  284. *****************************************************************************/
  285. UINT PASCAL
  286. _Repair_GetCachePath(HWND hdlg, LPTSTR ptszBuf)
  287. {
  288. _Repair_GetIEPath(ptszBuf, c_tszIECache, c_tszTempInet);
  289. return IDX_TEMPINET;
  290. }
  291. /*****************************************************************************
  292. *
  293. * _Repair_RepairJunction
  294. *
  295. * Hack at a junction to make it magic again.
  296. *
  297. *****************************************************************************/
  298. UINT PASCAL
  299. _Repair_RepairJunction(HWND hdlg, REPAIRPATHPROC GetRepairPath)
  300. {
  301. PIDL pidlFonts;
  302. TCHAR tsz[MAX_PATH];
  303. UINT ids;
  304. tsz[0] = TEXT('\0');
  305. ids = GetRepairPath(hdlg, tsz);
  306. if (ids && tsz[0]) {
  307. /* Ignore error; might already exist */
  308. CreateDirectory(tsz, 0);
  309. /* Ignore error; might not have permission to change attributes */
  310. SetFileAttributes(tsz, FILE_ATTRIBUTE_SYSTEM);
  311. lstrcpy(TweakUi_TrimTrailingBs(tsz), c_tszBSDesktopIni);
  312. _Repair_FileFromResource(ids, tsz);
  313. }
  314. return IDS_MAYBEREBOOT;
  315. }
  316. /*****************************************************************************
  317. *
  318. * _Repair_RepairFontFolder
  319. *
  320. * The font folder is special in that if we can find a
  321. * DllRegisterServer, we will call it as well.
  322. *
  323. *****************************************************************************/
  324. typedef HRESULT (CALLBACK *DLLREGISTERSERVER)(void);
  325. UINT PASCAL
  326. _Repair_RepairFontFolder(HWND hdlg, REPAIRPATHPROC GetRepairPath)
  327. {
  328. UINT ids = _Repair_RepairJunction(hdlg, GetRepairPath);
  329. /*
  330. * Do this after we do the default repair so fontext has a chance
  331. * to override whatever we did.
  332. */
  333. HINSTANCE hinst = LoadLibrary("fontext.dll");
  334. if (hinst) {
  335. DLLREGISTERSERVER _DllRegisterServer =
  336. (DLLREGISTERSERVER)GetProcAddress(hinst, "DllRegisterServer");
  337. if (_DllRegisterServer) {
  338. _DllRegisterServer();
  339. }
  340. FreeLibrary(hinst);
  341. }
  342. return ids;
  343. }
  344. /*****************************************************************************
  345. *
  346. * _Repair_RepairIconCache
  347. *
  348. * Rebuild the icon cache.
  349. *
  350. *****************************************************************************/
  351. UINT PASCAL
  352. _Repair_RepairIconCache(HWND hdlg, REPAIRPATHPROC GetRepairPath)
  353. {
  354. Misc_RebuildIcoCache();
  355. return 0;
  356. }
  357. /*****************************************************************************
  358. *
  359. * _Repair_RepairRegedit
  360. *
  361. * Nuke the saved view goo so Regedit won't be hosed.
  362. *
  363. *****************************************************************************/
  364. UINT PASCAL
  365. _Repair_RepairRegedit(HWND hdlg, REPAIRPATHPROC GetRepairPath)
  366. {
  367. DelPkl(&c_klRegView);
  368. return 0;
  369. }
  370. /*****************************************************************************
  371. *
  372. * _Repair_RepairAssociations
  373. *
  374. * Rebuild the associations.
  375. *
  376. *****************************************************************************/
  377. UINT PASCAL
  378. _Repair_RepairAssociations(HWND hdlg, REPAIRPATHPROC GetRepairPath)
  379. {
  380. if (MessageBoxId(hdlg, IDS_DESKTOPRESETOK,
  381. g_tszName, MB_YESNO + MB_DEFBUTTON2) == IDYES) {
  382. pcdii->fRunShellInf = 1;
  383. Common_NeedLogoff(hdlg);
  384. PropSheet_Apply(GetParent(hdlg));
  385. }
  386. return 0;
  387. }
  388. /*****************************************************************************
  389. *
  390. * _Repair_RepairHotkeys
  391. *
  392. * Rebuild the Start Menu hotkey list.
  393. *
  394. *****************************************************************************/
  395. UINT PASCAL
  396. _Repair_RepairHotkeys(HWND hdlg, REPAIRPATHPROC GetRepairPath)
  397. {
  398. SetRegStr(g_hkCUSMWCV, TEXT("RunOnce"),
  399. TEXT("TweakUI_RepairHotkeys"),
  400. TEXT("RUNDLL32.EXE TWEAKUI.CPL,RepairHotkeys"));
  401. MessageBoxId(hdlg, IDS_REPAIRLOGONOFF, g_tszName, MB_OK);
  402. return 0;
  403. }
  404. /*****************************************************************************
  405. *
  406. * RepairHotkeys
  407. *
  408. * Rundll entry point.
  409. *
  410. * This must be run during RunOnce because it has to do its work while
  411. * the tray does not exist. The tray loads settings when it is created,
  412. * and it saves them when it is destroyed. So if you try to clean up
  413. * the hotkeys
  414. *
  415. *****************************************************************************/
  416. void EXPORT
  417. RepairHotkeys(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
  418. {
  419. RegDeleteKey(pcdii->hkCUExplorer, TEXT("Hotkeys"));
  420. }
  421. /*****************************************************************************
  422. *
  423. * Repair_IsWin95
  424. *
  425. * Nonzero if we are on Windows 95.
  426. *
  427. *****************************************************************************/
  428. BOOL PASCAL
  429. Repair_IsWin95(void)
  430. {
  431. return !g_fNT;
  432. }
  433. /*****************************************************************************
  434. *
  435. * Repair_IsIE3
  436. *
  437. * Nonzero if we are on IE3 or better.
  438. *
  439. *****************************************************************************/
  440. BOOL PASCAL
  441. Repair_IsIE3(void)
  442. {
  443. return g_hkCUSMIE ? TRUE : FALSE;
  444. }
  445. /*****************************************************************************
  446. *
  447. * Repair_IsIE3or4
  448. *
  449. * Nonzero if we are on IE3 or IE4, but not IE5.
  450. *
  451. *****************************************************************************/
  452. BOOL PASCAL
  453. Repair_IsIE3or4(void)
  454. {
  455. return g_hkCUSMIE && !g_fIE5 ? TRUE : FALSE;
  456. }
  457. /*****************************************************************************
  458. *
  459. * REPAIRINFO
  460. *
  461. *****************************************************************************/
  462. typedef struct REPAIRINFO {
  463. BOOL (PASCAL *CanRepair)(void);
  464. UINT (PASCAL *Repair)(HWND hdlg, REPAIRPATHPROC GetRepairPath);
  465. REPAIRPATHPROC GetRepairPath;
  466. } REPAIRINFO, *PREPAIRINFO;
  467. /*
  468. * Note that this needs to be in sync with the IDS_REPAIR strings.
  469. */
  470. struct REPAIRINFO c_rgri[] = {
  471. { 0,
  472. _Repair_RepairIconCache,
  473. 0,
  474. }, /* Rebuild Icons */
  475. { 0,
  476. _Repair_RepairFontFolder,
  477. _Repair_GetFontPath,
  478. }, /* Repair Font Folder */
  479. { Repair_IsWin95,
  480. _Repair_RunSetup,
  481. 0,
  482. }, /* Repair System Files */
  483. { 0,
  484. _Repair_RepairRegedit,
  485. 0,
  486. }, /* Rebuild Regedit */
  487. { Repair_IsWin95,
  488. _Repair_RepairAssociations,
  489. 0,
  490. }, /* Repair Associations */
  491. { Repair_IsIE3or4, // Busted on IE5
  492. _Repair_RepairJunction,
  493. _Repair_GetHistoryPath,
  494. }, /* Repair URL History */
  495. { Repair_IsIE3,
  496. _Repair_RepairJunction,
  497. _Repair_GetCachePath,
  498. }, /* Repair Temporary Internet Files */
  499. {
  500. 0,
  501. _Repair_RepairHotkeys,
  502. 0,
  503. }, /* Repair hotkeys */
  504. };
  505. #pragma END_CONST_DATA
  506. /*****************************************************************************
  507. *
  508. * Repair_GetCurSelIndex
  509. *
  510. * Get the index of the selected item.
  511. *
  512. *****************************************************************************/
  513. INT_PTR PASCAL
  514. Repair_GetCurSelIndex(HWND hdlg)
  515. {
  516. HWND hwnd = GetDlgItem(hdlg, IDC_REPAIRCOMBO);
  517. INT_PTR iItem = ComboBox_GetCurSel(hwnd);
  518. if (iItem >= 0) {
  519. return ComboBox_GetItemData(hwnd, iItem);
  520. } else {
  521. return iItem;
  522. }
  523. }
  524. /*****************************************************************************
  525. *
  526. * Repair_OnSelChange
  527. *
  528. * Ooh, the selection changed.
  529. *
  530. *****************************************************************************/
  531. void PASCAL
  532. Repair_OnSelChange(HWND hdlg)
  533. {
  534. HWND hwnd = GetDlgItem(hdlg, IDC_REPAIRCOMBO);
  535. int dids = (int)Repair_GetCurSelIndex(hdlg);
  536. if (dids >= 0) {
  537. TCHAR tsz[1024];
  538. LoadString(hinstCur, IDS_REPAIRHELP+dids, tsz, cA(tsz));
  539. SetDlgItemText(hdlg, IDC_REPAIRHELP, tsz);
  540. }
  541. }
  542. /*****************************************************************************
  543. *
  544. * Repair_OnInitDialog
  545. *
  546. * Disable the shell.inf thing on NT, because NT doesn't have one.
  547. *
  548. *****************************************************************************/
  549. BOOL PASCAL
  550. Repair_OnInitDialog(HWND hdlg)
  551. {
  552. HWND hwnd = GetDlgItem(hdlg, IDC_REPAIRCOMBO);
  553. int dids;
  554. for (dids = 0; dids < cA(c_rgri); dids++) {
  555. if (c_rgri[dids].CanRepair == 0 ||
  556. c_rgri[dids].CanRepair()) {
  557. TCHAR tsz[MAX_PATH];
  558. int iItem;
  559. LoadString(hinstCur, IDS_REPAIR+dids, tsz, cA(tsz));
  560. iItem = ComboBox_AddString(hwnd, tsz);
  561. ComboBox_SetItemData(hwnd, iItem, dids);
  562. }
  563. }
  564. ComboBox_SetCurSel(hwnd, 0);
  565. Repair_OnSelChange(hdlg);
  566. return 1;
  567. }
  568. /*****************************************************************************
  569. *
  570. * Repair_OnRepairNow
  571. *
  572. * Ooh, go repair something.
  573. *
  574. *****************************************************************************/
  575. void PASCAL
  576. Repair_OnRepairNow(HWND hdlg)
  577. {
  578. HWND hwnd = GetDlgItem(hdlg, IDC_REPAIRCOMBO);
  579. int dids = (int)Repair_GetCurSelIndex(hdlg);
  580. if (dids >= 0) {
  581. UINT ids = c_rgri[dids].Repair(hdlg, c_rgri[dids].GetRepairPath);
  582. if (ids) {
  583. MessageBoxId(hdlg, ids, g_tszName, MB_OK);
  584. }
  585. }
  586. }
  587. /*****************************************************************************
  588. *
  589. * Repair_OnCommand
  590. *
  591. * Ooh, we got a command.
  592. *
  593. *****************************************************************************/
  594. BOOL PASCAL
  595. Repair_OnCommand(HWND hdlg, int id, UINT codeNotify)
  596. {
  597. switch (id) {
  598. case IDC_REPAIRCOMBO:
  599. if (codeNotify == CBN_SELCHANGE) {
  600. Repair_OnSelChange(hdlg);
  601. }
  602. break;
  603. case IDC_REPAIRNOW:
  604. if (codeNotify == BN_CLICKED) {
  605. Repair_OnRepairNow(hdlg);
  606. }
  607. }
  608. #if 0
  609. switch (id) {
  610. case IDC_REBUILDCACHE:
  611. if (codeNotify == BN_CLICKED) {
  612. Misc_RebuildIcoCache();
  613. MessageBoxId(hdlg, IDS_ICONSREBUILT, g_tszName, MB_OK);
  614. }
  615. break;
  616. case IDC_REPAIRFONTFLD:
  617. if (codeNotify == BN_CLICKED) {
  618. if (_Repair_RepairFontFolder(hdlg)) {
  619. MessageBoxId(hdlg, IDS_MAYBEREBOOT, g_tszName, MB_OK);
  620. }
  621. }
  622. break;
  623. case IDC_REPAIRREGEDIT:
  624. if (codeNotify == BN_CLICKED) {
  625. DelPkl(&c_klRegView);
  626. }
  627. break;
  628. case IDC_REPAIRASSOC:
  629. if (codeNotify == BN_CLICKED) {
  630. if (MessageBoxId(hdlg, IDS_DESKTOPRESETOK,
  631. g_tszName, MB_YESNO + MB_DEFBUTTON2) == IDYES) {
  632. pcdii->fRunShellInf = 1;
  633. Common_NeedLogoff(hdlg);
  634. PropSheet_Apply(GetParent(hdlg));
  635. }
  636. }
  637. break;
  638. case IDC_REPAIRDLLS:
  639. if (codeNotify == BN_CLICKED) {
  640. if (_Repair_RunSetup(hdlg)) {
  641. MessageBoxId(hdlg, IDS_MAYBEREBOOT, g_tszName, MB_OK);
  642. }
  643. }
  644. break;
  645. }
  646. #endif
  647. return 0;
  648. }
  649. #if 0
  650. /*****************************************************************************
  651. *
  652. * Repair_OnNotify
  653. *
  654. * Ooh, we got a notification.
  655. *
  656. *****************************************************************************/
  657. BOOL PASCAL
  658. Repair_OnNotify(HWND hdlg, NMHDR FAR *pnm)
  659. {
  660. switch (pnm->code) {
  661. case PSN_APPLY:
  662. Repair_Apply(hdlg);
  663. break;
  664. }
  665. return 0;
  666. }
  667. #endif
  668. /*****************************************************************************
  669. *
  670. * Our window procedure.
  671. *
  672. *****************************************************************************/
  673. /*
  674. * The HANDLE_WM_* macros weren't designed to be used from a dialog
  675. * proc, so we need to handle the messages manually. (But carefully.)
  676. */
  677. INT_PTR EXPORT
  678. Repair_DlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam)
  679. {
  680. switch (wm) {
  681. case WM_INITDIALOG: return Repair_OnInitDialog(hdlg);
  682. case WM_COMMAND:
  683. return Repair_OnCommand(hdlg,
  684. (int)GET_WM_COMMAND_ID(wParam, lParam),
  685. (UINT)GET_WM_COMMAND_CMD(wParam, lParam));
  686. #if 0
  687. case WM_NOTIFY:
  688. return Repair_OnNotify(hdlg, (NMHDR FAR *)lParam);
  689. #endif
  690. case WM_HELP: Common_OnHelp(lParam, &rgdwHelp[0]); break;
  691. case WM_CONTEXTMENU: Common_OnContextMenu(wParam, &rgdwHelp[0]); break;
  692. default: return 0; /* Unhandled */
  693. }
  694. return 1; /* Handled */
  695. }