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.

116 lines
4.2 KiB

  1. /*++
  2. w95fdump.c
  3. Copyright (c) 1997 Microsoft Corporation
  4. This utility dumps configuration information about the win95 fax.
  5. It pulls this information from the registry...
  6. This is primarily a warm-up application for win95->NT migration; the migration
  7. DLL will need to get all of this information to configure the NT setup.
  8. Author:
  9. Brian Dewey (t-briand) 1997-7-18
  10. --*/
  11. #include <windows.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <tchar.h>
  15. #include <setupapi.h>
  16. #include "migrate.h" // Includes my migration prototypes.
  17. // ------------------------------------------------------------
  18. // Prototypes
  19. BOOL EnumUsers();
  20. // ------------------------------------------------------------
  21. // main
  22. int _cdecl
  23. main(int argc, char *argv[])
  24. {
  25. LPCSTR ProductID; // Will hold the ID string from my DLL.
  26. UINT DllVersion; // Holds the version of the DLL.
  27. LPINT CodePageArray; // Locale info.
  28. LPCSTR ExeNamesBuf; // Executables to look for.
  29. LPVOID Reserved = NULL; // Placeholder.
  30. // Print banner.
  31. fprintf(stderr, "Win32 Fax Configuration Dump Utility\n");
  32. fprintf(stderr, "Copyright (c) 1997 Microsoft Corporation\n");
  33. QueryVersion(&ProductID, &DllVersion, &CodePageArray, &ExeNamesBuf, Reserved);
  34. fprintf(stderr, "Library '%s' version %d.\n", ProductID, DllVersion);
  35. // Simulate the initialization.
  36. Initialize9x(".", ".", Reserved);
  37. // This will try to gather all user information.
  38. if(EnumUsers())
  39. fprintf(stderr, "User migration succeeded.\n");
  40. else {
  41. fprintf(stderr, "User migration failed, exiting...\n");
  42. return 1;
  43. }
  44. // Finally, try to migrate the system.
  45. if(MigrateSystem9x(NULL, ".\\unattend.txt", Reserved) != ERROR_SUCCESS) {
  46. fprintf(stderr, "System migration failed.\n");
  47. return 1;
  48. } else {
  49. fprintf(stderr, "System migration succeeded.\n");
  50. }
  51. return 0;
  52. }
  53. // ------------------------------------------------------------
  54. // Auxiliary functions
  55. BOOL
  56. EnumUsers()
  57. {
  58. DWORD dwIndex; // Index of the HKEY_USERS subkey.
  59. TCHAR szKeyName[MAX_PATH]; // Name of the subkey.
  60. DWORD cbBufSize; // Size of the name buffer.
  61. FILETIME ftTime; // Will hold the time the key was last modified.
  62. HKEY hUserKey; // Registry key for a user.
  63. LONG lResult; // Result codes from API calls.
  64. LONGLONG llDiskSpace, // Total disk space used.
  65. llComponentSpace; // Component space required.
  66. dwIndex = 0;
  67. cbBufSize = sizeof(szKeyName);
  68. while(RegEnumKeyEx(HKEY_USERS, // We're enumerating through the users.
  69. dwIndex++, // Keep incrementing the index!
  70. szKeyName, // Will hold the name of the subkey.
  71. &cbBufSize, // Will hold the # of characters in the key name.
  72. NULL, // Reserved; must be NULL.
  73. NULL, // Class info (I don't need this).
  74. NULL, // size of class info -- not needed.
  75. &ftTime) == ERROR_SUCCESS) {
  76. _tprintf(TEXT("User %s.\n"), szKeyName);
  77. // Open the key.
  78. if((lResult = RegOpenKeyEx(HKEY_USERS,
  79. szKeyName,
  80. 0, // Zero options.
  81. KEY_READ, // Read-only permission.
  82. &hUserKey)) != ERROR_SUCCESS) {
  83. // FIXBKD: Use FormatMessage
  84. _ftprintf(stderr, TEXT("EnumUsers:Unable to open key for user %s.\n"),
  85. szKeyName);
  86. return FALSE;
  87. }
  88. // Call the migration DLL MigrateUser9x routine.
  89. MigrateUser9x(
  90. NULL, // No window for UI.
  91. "unattend.txt", // Sample unattend file.
  92. hUserKey, // Key to the user's part of the registry.
  93. szKeyName, // Pass in the user's name.
  94. &llComponentSpace // Receive the amount of space needed.
  95. );
  96. RegCloseKey(hUserKey); // Close the key.
  97. cbBufSize = sizeof(szKeyName); // Reset size indicator.
  98. }
  99. return TRUE;
  100. }