--The ListBox I'm using is named here. So u dont need to type a lot and u know what it is. LB = "LB_Drive"; --Clear Previous Entry ListBox.DeleteItem(LB, -1); --Disable listbox Updating ListBox.SetUpdate(LB, false); --Make Suitable objects appear, otherwise remain invisible ListBox.SetVisible(LB, true); Label.SetVisible("Label1", true); Paragraph.SetVisible("Para_DriveProps", true); Paragraph.SetVisible("Para_Note", true); Button.SetVisible("Button_Install", true); Button.SetVisible("Button_ClearListDrive", true); -- Get a list of the available drives. tDrives = Drive.Enumerate(); -- Determine if an error occurred. error = Application.GetLastError(); -- If an error occurred, display the error message. -- If no error occurred, display the available drives in a dialog. if (error ~= 0) then Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1); else --do the following for each drive. Info on the numbering in Help File for i,sDrive in pairs(tDrives) do nType=Drive.GetType(sDrive) if nType==0 then nType = "UNKNOWN"; elseif nType==1 then nType = "INVALID"; elseif nType==2 then nType = "REMOVABLE"; elseif nType==3 then nType = "HARD-DRIVE"; elseif nType==4 then nType = "NETWORK-DRIVE"; elseif nType==5 then nType = "CD-ROM"; elseif nType==6 then nType = "RAM DISK"; end sText = sDrive; nSpace = Drive.GetFreeSpace(sDrive); -- this gets the unused space in drive nSize = Drive.GetSize(sDrive); -- this gets the full size of the drive if nSpace == -1 then -- the output is -1 if drive is not loaded nSpace = "DRIVE NOT LOADED"; sData = "Drive Type : "..nType.."\r\nAvailable Space : "..nSpace; else if nType=="HARD-DRIVE" or nType=="NETWORK-DRIVE" or nType=="RAM DISK" or nType=="REMOVABLE" then sData = "Drive : "..sDrive.." ["..nType.."]\r\nAvailable Space : "..Math.Round(nSpace/1024,2).." GB / "..Math.Round(nSize/1024,2).." GB".." - [ "..Math.Round(nSpace,2).." Mb / "..Math.Round(nSize,2).." Mb ]"; elseif nType=="CD-ROM" then sData = "Drive : "..sDrive.." ["..nType.."]\r\nSpace Used : "..Math.Round(nSize/1024,2).." GB".." - [ "..Math.Round(nSize,2).." Mb ]"; end end --add the item to the listbox, with the name visible and path as data if nType == "HARD-DRIVE" then ListBox.AddItem(LB, sText, sData); end end end --Allow the listbox to display the updated content ListBox.SetUpdate(LB, true); |