Quote:
Originally Posted by audiofeel
Preliminarily... failure at startup occurs only if the script is built on version 5.6.1. On version 6.2.2, I have not noticed any failures yet. I could be wrong . It is possible that something is wrong with my pc machine. Or I have a mistake in the script.
youtu.be
|
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);
.