@@ -367,7 +367,6 @@ int wmain(int argc, WCHAR *argv[])
367367 WCHAR volumeName [1024 ] = {0 };
368368 WCHAR input [1024 ];
369369 DWORD serialNumber ;
370- DWORD flags , maxComponent ;
371370 ULARGE_INTEGER freeBytesAvailableToCaller , totalNumberOfBytes , totalNumberOfFreeBytes ;
372371 WCHAR szMsg [RC_STRING_MAX_SIZE ];
373372
@@ -468,11 +467,11 @@ int wmain(int argc, WCHAR *argv[])
468467 }
469468
470469 //
471- // Determine the drive's file system format
470+ // Get the existing name and file system, and print out the latter
472471 //
473472 if (!GetVolumeInformationW (RootDirectory ,
474473 volumeName , ARRAYSIZE (volumeName ),
475- & serialNumber , & maxComponent , & flags ,
474+ NULL , NULL , NULL ,
476475 fileSystem , ARRAYSIZE (fileSystem )))
477476 {
478477 if (GetLastError () == ERROR_UNRECOGNIZED_VOLUME )
@@ -487,6 +486,8 @@ int wmain(int argc, WCHAR *argv[])
487486 }
488487 }
489488
489+ ConResPrintf (StdOut , STRING_FILESYSTEM , fileSystem );
490+
490491 if (QueryDeviceInformation (RootDirectory ,
491492 & DeviceInformation ,
492493 sizeof (DeviceInformation )))
@@ -508,7 +509,6 @@ int wmain(int argc, WCHAR *argv[])
508509 PrintWin32Error (szMsg , GetLastError ());
509510 return -1 ;
510511 }
511- ConResPrintf (StdOut , STRING_FILESYSTEM , fileSystem );
512512
513513 //
514514 // Make sure they want to do this
@@ -611,16 +611,6 @@ int wmain(int argc, WCHAR *argv[])
611611 }
612612 }
613613
614- if (!GetVolumeInformationW (RootDirectory ,
615- volumeName , ARRAYSIZE (volumeName ),
616- & serialNumber , & maxComponent , & flags ,
617- fileSystem , ARRAYSIZE (fileSystem )))
618- {
619- K32LoadStringW (GetModuleHandle (NULL ), STRING_NO_VOLUME , szMsg , ARRAYSIZE (szMsg ));
620- PrintWin32Error (szMsg , GetLastError ());
621- return -1 ;
622- }
623-
624614 //
625615 // Print out some stuff including the formatted size
626616 //
@@ -638,17 +628,18 @@ int wmain(int argc, WCHAR *argv[])
638628 totalNumberOfFreeBytes .QuadPart );
639629
640630 //
641- // Get the drive's serial number
631+ // Get and print out the new serial number
642632 //
643633 if (!GetVolumeInformationW (RootDirectory ,
644- volumeName , ARRAYSIZE ( volumeName ) ,
645- & serialNumber , & maxComponent , & flags ,
646- fileSystem , ARRAYSIZE ( fileSystem ) ))
634+ NULL , 0 ,
635+ & serialNumber , NULL , NULL ,
636+ NULL , 0 ))
647637 {
648638 K32LoadStringW (GetModuleHandle (NULL ), STRING_NO_VOLUME , szMsg , ARRAYSIZE (szMsg ));
649639 PrintWin32Error (szMsg , GetLastError ());
650640 return -1 ;
651641 }
642+
652643 ConResPrintf (StdOut , STRING_SERIAL_NUMBER ,
653644 (unsigned int )(serialNumber >> 16 ),
654645 (unsigned int )(serialNumber & 0xFFFF ));
0 commit comments