update disk sort compare

This commit is contained in:
longpanda 2021-02-24 00:07:44 +08:00
parent fd6580be72
commit 3929ed55ca
1 changed files with 22 additions and 3 deletions

View File

@ -316,15 +316,35 @@ PHY_DRIVE_INFO * GetPhyDriveInfoById(int Id)
int SortPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
{
DWORD i, j;
BOOL flag;
PHY_DRIVE_INFO TmpDriveInfo;
for (i = 0; i < DriveCount; i++)
{
for (j = i + 1; j < DriveCount; j++)
{
flag = FALSE;
if (pDriveList[i].BusType == BusTypeUsb && pDriveList[j].BusType == BusTypeUsb)
{
if (pDriveList[i].RemovableMedia == FALSE && pDriveList[j].RemovableMedia == TRUE)
{
flag = TRUE;
}
}
else if (pDriveList[j].BusType == BusTypeUsb)
{
flag = TRUE;
}
else
{
if (pDriveList[j].PhyDrive < pDriveList[i].PhyDrive)
{
flag = TRUE;
}
}
if (flag)
{
memcpy(&TmpDriveInfo, pDriveList + i, sizeof(PHY_DRIVE_INFO));
memcpy(pDriveList + i, pDriveList + j, sizeof(PHY_DRIVE_INFO));
@ -332,7 +352,6 @@ int SortPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
}
}
}
}
return 0;
}