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.

247 lines
7.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. uninstal.c
  5. Abstract:
  6. This file implements the un-install case.
  7. Environment:
  8. WIN32 User Mode
  9. Author:
  10. Wesley Witt (wesw) 17-Feb-1996
  11. --*/
  12. #include "wizard.h"
  13. #pragma hdrstop
  14. FILE_QUEUE_INFO UninstallFileQueue[] =
  15. {
  16. //---------------------------------------------------------------------------------------------------------------------------------------
  17. // Section Name Dest Dir INF Dir Id Dest Dir Id Platforms Copy Flags
  18. //---------------------------------------------------------------------------------------------------------------------------------------
  19. { TEXT("ServerSystemFiles"), NULL, DIRID_SYSTEM, DIRID_SYSTEM, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  20. { TEXT("ServerPrinterFiles"), NULL, PRINTER_DRIVER_DIR, DIRID_SPOOLDRIVERS, PLATFORM_USE_PRINTER, SP_COPY_IN_USE_NEEDS_REBOOT },
  21. { TEXT("HelpFilesCommon"), NULL, DIRID_HELP, DIRID_HELP, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  22. { TEXT("HelpFilesClient"), NULL, DIRID_HELP, DIRID_HELP, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  23. { TEXT("HelpFilesWorkstation"), NULL, DIRID_HELP, DIRID_HELP, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  24. { TEXT("HelpFilesServer"), NULL, DIRID_HELP, DIRID_HELP, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  25. { TEXT("ClientFiles"), FAXCLIENTS_DIR, PRINTER_CLIENT_DIR, DIRID_SPOOLDRIVERS, PLATFORM_USE_MACHINE, SP_COPY_IN_USE_NEEDS_REBOOT },
  26. { TEXT("ClientCoverPageFiles"), COVERPAGE_DIR, COVERPAGE_CLIENT_DIR, DIRID_SPOOLDRIVERS, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  27. { TEXT("ClientSystemFiles"), NULL, DIRID_SYSTEM, DIRID_SYSTEM, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  28. { TEXT("ClientCoverPageFiles"), COVERPAGE_DIR, COVERPAGE_CLIENT_DIR, DIRID_SYSTEM, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT },
  29. { TEXT("OutlookConfigFile"), OUTLOOKCONFIG_DIR, OUTLOOK_ECF_DIR, DIRID_WINDOWS, PLATFORM_NONE, SP_COPY_IN_USE_NEEDS_REBOOT }
  30. };
  31. #define CountUninstallFileQueue (sizeof(UninstallFileQueue)/sizeof(FILE_QUEUE_INFO))
  32. UINT
  33. UninstallQueueCallback(
  34. IN PVOID QueueContext,
  35. IN UINT Notification,
  36. IN UINT Param1,
  37. IN UINT Param2
  38. )
  39. {
  40. LPTSTR TextBuffer;
  41. DWORD len;
  42. TCHAR Drive[_MAX_DRIVE];
  43. TCHAR Dir[_MAX_DIR];
  44. TCHAR Path[MAX_PATH];
  45. PFILE_QUEUE_CONTEXT FileQueueContext = (PFILE_QUEUE_CONTEXT) QueueContext;
  46. if (Notification == SPFILENOTIFY_ENDDELETE) {
  47. _tsplitpath( ((PFILEPATHS)Param1)->Target, Drive, Dir, NULL, NULL );
  48. _stprintf( Path, TEXT("%s%s"), Drive, Dir );
  49. RemoveDirectory( Path );
  50. } else if (Notification == SPFILENOTIFY_STARTDELETE) {
  51. TextBuffer = MemAlloc(
  52. ((_tcslen( ((PFILEPATHS)Param1)->Target ) + 32) * sizeof(TCHAR))
  53. );
  54. if (TextBuffer) {
  55. _stprintf(
  56. TextBuffer,
  57. TEXT("%s%s"),
  58. GetString( IDS_DELETING ),
  59. ((PFILEPATHS)Param1)->Target
  60. );
  61. len = ExtraChars( GetDlgItem( FileQueueContext->hwnd, IDC_PROGRESS_TEXT ), TextBuffer );
  62. if (len) {
  63. LPTSTR FileName = CompactFileName( ((PFILEPATHS)Param1)->Target, len );
  64. _stprintf(
  65. TextBuffer,
  66. TEXT("%s%s"),
  67. GetString( IDS_DELETING ),
  68. FileName
  69. );
  70. MemFree( FileName );
  71. }
  72. SetDlgItemText(
  73. FileQueueContext->hwnd,
  74. IDC_PROGRESS_TEXT,
  75. TextBuffer
  76. );
  77. DebugPrint(( TEXT("%s"), TextBuffer ));
  78. MemFree( TextBuffer );
  79. }
  80. }
  81. //
  82. // Want default processing.
  83. //
  84. return SetupDefaultQueueCallback( FileQueueContext->QueueContext, Notification, Param1, Param2 );
  85. }
  86. DWORD
  87. UninstallThread(
  88. HWND hwnd
  89. )
  90. {
  91. HINF FaxSetupInf;
  92. HSPFILEQ *FileQueue;
  93. PVOID QueueContext;
  94. DWORD ErrorCode = 0;
  95. HKEY hKey;
  96. HKEY hKeyDevice;
  97. DWORD RegSize;
  98. DWORD RegType;
  99. LONG rVal;
  100. DWORD i = 0;
  101. WCHAR Buffer[MAX_PATH*2];
  102. SendMessage( hwnd, WM_MY_PROGRESS, 0xff, 40 );
  103. //
  104. // delete all the files
  105. //
  106. if ( !InitializeFileQueue( hwnd, &FaxSetupInf, &FileQueue, &QueueContext, SourceDirectory )) {
  107. ErrorCode = IDS_COULD_NOT_DELETE_FILES;
  108. goto error_exit;
  109. }
  110. SetProgress( hwnd, IDS_DELETING_FAX_PRINTERS );
  111. DeleteFaxPrinters( hwnd );
  112. if (!ProcessFileQueue( FaxSetupInf, FileQueue, QueueContext, SourceDirectory,
  113. UninstallFileQueue, CountUninstallFileQueue, UninstallQueueCallback, SETUP_ACTION_DELETE )) {
  114. ErrorCode = IDS_COULD_NOT_DELETE_FILES;
  115. goto error_exit;
  116. }
  117. if (!CloseFileQueue( FileQueue, QueueContext )) {
  118. ErrorCode = IDS_COULD_NOT_DELETE_FILES;
  119. goto error_exit;
  120. }
  121. //
  122. // kill the clients dir
  123. //
  124. wcscpy( Buffer, Platforms[0].DriverDir );
  125. RemoveLastNode( Buffer );
  126. wcscat( Buffer, FAXCLIENTS_DIR );
  127. DeleteDirectoryTree( Buffer );
  128. //
  129. // kill the fax receieve dir(s)
  130. //
  131. rVal = RegOpenKey( HKEY_LOCAL_MACHINE, REGKEY_FAX_DEVICES, &hKey );
  132. if (rVal == ERROR_SUCCESS) {
  133. while (RegEnumKey( hKey, i++, Buffer, sizeof(Buffer)/sizeof(WCHAR) ) == ERROR_SUCCESS) {
  134. wcscat( Buffer, L"\\" );
  135. wcscat( Buffer, REGKEY_ROUTING );
  136. rVal = RegOpenKey( hKey, Buffer, &hKeyDevice );
  137. if (rVal == ERROR_SUCCESS) {
  138. RegSize = sizeof(Buffer);
  139. rVal = RegQueryValueEx(
  140. hKeyDevice,
  141. REGVAL_ROUTING_DIR,
  142. 0,
  143. &RegType,
  144. (LPBYTE) Buffer,
  145. &RegSize
  146. );
  147. if (rVal == ERROR_SUCCESS) {
  148. DeleteDirectoryTree( Buffer );
  149. }
  150. RegCloseKey( hKeyDevice );
  151. }
  152. }
  153. RegCloseKey( hKey );
  154. }
  155. //
  156. // clean out the registry
  157. //
  158. SetProgress( hwnd, IDS_DELETING_REGISTRY );
  159. DeleteFaxRegistryData();
  160. //
  161. // remove the fax service
  162. //
  163. SetProgress( hwnd, IDS_DELETING_FAX_SERVICE );
  164. MyDeleteService( TEXT("Fax") );
  165. //
  166. // remove the program groups
  167. //
  168. SetProgress( hwnd, IDS_DELETING_GROUPS );
  169. DeleteGroupItems();
  170. DeleteFaxMsgServices();
  171. if (InstallType & FAX_INSTALL_SERVER) {
  172. DeleteNetworkShare( FAXCLIENTS_DIR );
  173. }
  174. //
  175. // allow the ui to continue
  176. //
  177. SetWindowLong( hwnd, DWL_MSGRESULT, 0 );
  178. PropSheet_PressButton( GetParent(hwnd), PSBTN_NEXT );
  179. return TRUE;
  180. error_exit:
  181. PopUpMsg( hwnd, ErrorCode, TRUE, 0 );
  182. OkToCancel = TRUE;
  183. PropSheet_PressButton( GetParent(hwnd), PSBTN_CANCEL );
  184. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  185. return FALSE;
  186. }