Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enumerate hard disks, exclude partitions
#16
I added a dialog, but only one line of text is displayed on the label control. In addition to the third function, I am writing code that is difficult to complete.


Macro Macro2
Code:
Copy      Help
_s.expandpath("$desktop$\diskpartinfo.txt")
str s cl=F"cmd.exe /C diskpart /s ''{_s}''"
RunConsole2 cl s
s.trim
int i t tt ttt tttt
str ss disklist partitionlist1 partitionlist2
ARRAY(str) a=s
for(i a.len-1 -1 -1)
,if a[i].len = 0
,,a.remove(i)
for i 0 a.len
,a[i].trim
,ss=a[i]
,;out ss
,if(findrx(ss "Disk(?=\s\d*\s+Online)" 0 0) >=0)
,,if ttt=0
,,,disklist+ ss
,,,ttt+1
,,else
,,,disklist+"[]"
,,,disklist+ ss
,,,ttt+1
,if ss="Disk 0 is now the selected disk."
,,t=find(ss "Disk 0 is now the selected disk." 0 1)
,if ss!="Disk 1 is now the selected disk."
,,if(findrx(ss "Partition(?=\s\d+)" t 0 0)>=0)
,,,if tt=0
,,,,partitionlist1+ ss
,,,,tt+1
,,,else
,,,,partitionlist1 + "[]"
,,,,partitionlist1 +ss
,,,,tt+1
,if ss="Disk 1 is now the selected disk."
,,t=0
,,t=find(ss "Disk 1 is now the selected disk." 0 1)
,,tttt=1
,if tttt=1
,,if(findrx(ss "Partition(?=\s\d+)" t 0 0)>=0)
,,,partitionlist2+ ss
,,,tttt+1
,if tttt >1
,,if(findrx(ss "Partition(?=\s\d+)" t 0 0)>=0)
,,,partitionlist2 + "[]"
,,,partitionlist2 +ss
,,,tttt+1
;out disklist
int disknum= numlines(disklist)
int part1num= numlines(partitionlist1)
int part2num= numlines(partitionlist2)
str s1=
F
;You currently have {disknum} hard drives
;The first hard drive has {part1num} partitions
;The second hard drive has {part2num} partitions
mes s1


str dd=
F
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Static 0x54000000 0x0 12 12 198 82 "{s1}"
;4 Edit 0x54030080 0x200 161 100 38 14 ""
;5 Static 0x54000000 0x0 104 101 52 13 "excluded part:"
;6 Static 0x54000000 0x4 12 101 38 14 "select HD:"
;7 Edit 0x54030080 0x204 54 100 38 14 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "4 7"
str e4 e7
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Attached Files Image(s)
   


Messages In This Thread
Enumerate hard disks, exclude partitions - by win - 09-08-2018, 09:34 PM
RE: Enumerate hard disks, exclude partitions - by win - 09-09-2018, 06:38 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)