Hi,
I want to make listview like below to show the drives.I can show the drives without problem.However I cant set system icon to the listview
Here is my code
This code shows the drives from last to first.Could someone help to make same listview like below picture?I want to select drives by double clicking which adds masks to the image.Thanks.
I want to make listview like below to show the drives.I can show the drives without problem.However I cant set system icon to the listview
Here is my code
sz_DRIVE_UNKNOWN db "Unknown drive",0
sz_DRIVE_NO_ROOT_DIR db "No root dir",0
sz_DRIVE_REMOVABLE db "Removable",0
sz_DRIVE_FIXED db "Local Disk",0
sz_DRIVE_REMOTE db "Network Drive",0
sz_DRIVE_CDROM db "CD-Rrom",0
sz_DRIVE_RAMDISK db "Ram Disk",0
szDriveTable dd offset sz_DRIVE_UNKNOWN
dd offset sz_DRIVE_NO_ROOT_DIR
dd offset sz_DRIVE_REMOVABLE
dd offset sz_DRIVE_FIXED
dd offset sz_DRIVE_REMOTE
dd offset sz_DRIVE_CDROM
dd offset sz_DRIVE_RAMDISK
invoke GetLogicalDriveStrings,sizeof szDrives,addr szDrives
lea esi,szDrives
@@:
invoke lstrlen,esi
test eax,eax
jz @F
invoke RtlZeroMemory,addr lvi,sizeof lvi
invoke RtlZeroMemory,addr sfi,sizeof sfi
invoke GetDriveType,esi
mov ebx,
mov lvi.imask,LVIF_TEXT or LVIF_IMAGE
mov lvi.iItem,0
mov lvi.iSubItem, 0
mov lvi.pszText, esi
invoke SHGetFileInfo, esi, 0, addr sfi, sizeof SHFILEINFO,\
SHGFI_SYSICONINDEX or SHGFI_SMALLICON
mov eax, sfi.iIcon
mov lvi.iImage, eax
invoke SendMessage,hListView,LVM_INSERTITEM,0,addr lvi
inc lvi.iSubItem
mov lvi.pszText, ebx
invoke SendMessage,hListView,LVM_SETITEM,0,addr lvi
invoke lstrlen,esi
add esi,eax
inc esi
jmp @B
@@:
This code shows the drives from last to first.Could someone help to make same listview like below picture?I want to select drives by double clicking which adds masks to the image.Thanks.
hi
i hope this help you
http://www.assembler.ca/files/WinExplorer.zip
greets
ragdog
i hope this help you
http://www.assembler.ca/files/WinExplorer.zip
greets
ragdog
You can also do one simple thing: create a loop that iterates from 65 (0x40) to 90 (0x5A). These values will represent 'A' to 'Z'. Then use the GetDriveType() Win32 API and determine the type of the drive if it exists. This way you will have them sorted and enumerated alphabetically and is much easier than using the GetLogicalDriveStrings() Win32 API.
GetDrives Proc
LOCAL pString:DWORD
LOCAL pvi :DWORD
LOCAL buffer[1024]:BYTE
LOCAL string[128]:BYTE
LOCAL vi[128]:BYTE
push esi
mov pvi, ptr$(vi)
invoke GetLogicalDriveStrings,1024,ADDR buffer
lea esi, buffer
sub esi, 1
lpst:
add esi, 1
invoke GetDriveType,esi
cmp eax, DRIVE_REMOVABLE
jne @F
invoke GetVolumeInformation,esi,pvi,128,0,0,0,0,0
mov pString, ptr$(string)
mov pString, cat$(pString,esi," ",chr$(40,20h),pvi,chr$(20h,41))
invoke SendMessage,hCombo,CB_ADDSTRING,0,pString
invoke SendMessage,hCombo,CB_SETCURSEL,0, 0
@@:
add esi, 1
cmp BYTE PTR , 0
jne @B
cmp BYTE PTR , 0
jne lpst
pop esi
ret
GetDrives endp
or
.const
DRIVE_NO_ROOT_DIR equ 1
.data
szstring db "%c:\",0
.code
GetDrive proc
LOCAL szComplete[255]:BYTE
LOCAL nChar:DWORD
mov nChar,65 ;loop through a-z
@@:
invoke wsprintf,addr szComplete, addr szstring, nChar
invoke GetDriveType,addr szComplete
.if eax!=DRIVE_NO_ROOT_DIR && DRIVE_CDROM
invoke MessageBox,0,addr szComplete,addr szComplete,MB_OK
.endif
inc nChar
cmp nChar,90
jl @B
ret
GetDrive endp
LOCAL pString:DWORD
LOCAL pvi :DWORD
LOCAL buffer[1024]:BYTE
LOCAL string[128]:BYTE
LOCAL vi[128]:BYTE
push esi
mov pvi, ptr$(vi)
invoke GetLogicalDriveStrings,1024,ADDR buffer
lea esi, buffer
sub esi, 1
lpst:
add esi, 1
invoke GetDriveType,esi
cmp eax, DRIVE_REMOVABLE
jne @F
invoke GetVolumeInformation,esi,pvi,128,0,0,0,0,0
mov pString, ptr$(string)
mov pString, cat$(pString,esi," ",chr$(40,20h),pvi,chr$(20h,41))
invoke SendMessage,hCombo,CB_ADDSTRING,0,pString
invoke SendMessage,hCombo,CB_SETCURSEL,0, 0
@@:
add esi, 1
cmp BYTE PTR , 0
jne @B
cmp BYTE PTR , 0
jne lpst
pop esi
ret
GetDrives endp
or
.const
DRIVE_NO_ROOT_DIR equ 1
.data
szstring db "%c:\",0
.code
GetDrive proc
LOCAL szComplete[255]:BYTE
LOCAL nChar:DWORD
mov nChar,65 ;loop through a-z
@@:
invoke wsprintf,addr szComplete, addr szstring, nChar
invoke GetDriveType,addr szComplete
.if eax!=DRIVE_NO_ROOT_DIR && DRIVE_CDROM
invoke MessageBox,0,addr szComplete,addr szComplete,MB_OK
.endif
inc nChar
cmp nChar,90
jl @B
ret
GetDrive endp
Thanks for winexplorer code. However my problem is related to adding icons of drives to the listview.I think it is at BuildDriveList function.However I cant decipher it ully and apply.I think I have an error in my SHGetFileInfo function.Could you help me to write just a simple app which adds drives with their icons to listview.Thanks.
please :D
for all interested, here is a example
regards
ragdog
for all interested, here is a example
regards
ragdog
Thanks for the example.I will work myself to add mask icon when item is selected with double click.If I cant do it myself I will bother you again :lol: Thanks very much again.