View Single Post
  #400  
Old 07-10-2023, 08:29
BLACKFIRE69's Avatar
BLACKFIRE69 BLACKFIRE69 is offline
Registered User
 
Join Date: Mar 2019
Location: In the Hell
Posts: 688
Thanks: 481
Thanked 2,547 Times in 561 Posts
BLACKFIRE69 is on a distinguished road
Question Testing

Testing:

guys, if any of you happen to have some free time and are using virtual machines other than VMware 17.x, could you please test this on them?











Quote:
Originally Posted by BLACKFIRE69 View Post
sorry for the delayed response; i've been quite busy these past few days and, to be honest, i haven't had a good night's sleep in two days.


it seems that the wGetLogicalDriveList function doesn't function as expected in InnoSetup v5.x. however, the FLogicalDrives class works reliably across all scenarios and has undergone thorough testing.


Code:
type
  FLogicalDrives = interface(IUnknown)
    '{73D9B3A3-6571-474E-B043-7DC8D3248538}'
    procedure FCreate;
    function Count: Integer;
    function CDriveIndex: Integer;
    function Letter(const Index: Integer): WideString;
    function LetterToIndex(const Letter: WideString): Integer;
    function IsRemovable(const Index: Integer): Boolean;
    function MediaType(const Index: Integer): Integer;
    function MediaTypeEx(const Index: Integer; out HealthStatus, Usage: Integer): Integer;
    function SpaceFreeMB(const Index: Integer): Integer;
    function SpaceAvailableMB(const Index: Integer): Integer;
    function SpaceTotalMB(const Index: Integer): Integer;
  end;

Code:
{ Drive Media Type }
const
  HDD_MEDIA_TYPE_UNKNOWN        = $0000;
  HDD_MEDIA_TYPE_USB            = $0001;
  HDD_MEDIA_TYPE_SD             = $0002;
  HDD_MEDIA_TYPE_HDD            = $0003;
  HDD_MEDIA_TYPE_SSD            = $0004;
  HDD_MEDIA_TYPE_SCM            = $0005;
  HDD_MEDIA_TYPE_NVMe           = $0006;

{ Drive Health }
const
  HDD_HEALTH_STATUS_HEALTHY     = $0000;
  HDD_HEALTH_STATUS_WARNING     = $0001;
  HDD_HEALTH_STATUS_UNHEALTHY   = $0002;
  HDD_HEALTH_STATUS_UNKNOWN     = $0005;

{ Drive Usage }
const
  HDD_USAGE_UNKWOWN             = $0000;
  HDD_USAGE_AUTO_SELECT         = $0001; // used for data storage.
  HDD_USAGE_MANUAL_SELECT       = $0002; // used if manually selected by an administrator at the time of virtual disk creation.
  HDD_USAGE_RETIRED             = $0004; // retired from use
  HDD_USAGE_CACHE               = $0005; // used as a cache for other devices.

Code:
  { LogicalDrives }
  LogicalDrives.FCreate;

  if LogicalDrives.Count > 0 then
  begin
    { ListBox }
    ListBox.FCreate(FMXForm.Handle);
    ListBox.SetBounds(NSX(32), NSY(53), NSX(297), NSY(249));
    ListBox.OnChange(@ListBoxOnChange);

    if ImgList.Count >= 2 then
      ListBox.ImageList(ImgList.Handle);

    { ListBox-Items }
    SetArrayLength(ListBoxItems, LogicalDrives.Count);

    ListBox.BeginUpdate;   // BeginUpdate
    for i := 0 to LogicalDrives.Count - 1 do
    begin
      ListBoxItems[i] := InitListBoxItemHandle;
      ListBoxItems[i].FCreate(ListBox.Handle);
      ListBoxItems[i].Text(LogicalDrives.Letter(i));

      if (ImgList.Count >= 2) then
      begin
        if (i = LogicalDrives.CDriveIndex) then  // C-Drive
          ListBoxItems[i].ImageIndex(0)
        else
          ListBoxItems[i].ImageIndex(1);
      end;

      ListBox.AddItem(ListBoxItems[i].Handle);
    end;
    ListBox.EndUpdate;     // EndUpdate
  end else
    MsgBox('"LogicalDrives" failded!', mbError, MB_OK);

.

Last edited by BLACKFIRE69; 07-10-2023 at 08:38.
Reply With Quote
The Following 2 Users Say Thank You to BLACKFIRE69 For This Useful Post:
audiofeel (07-10-2023), hitman797 (07-10-2023)