This is a source and the exe file which add all devices to the listbox. This file based on example from The Assembly Programming Master Book. Additionali the window and listbox are sizable. Hope someone can use this
format PE GUI 4.0
entry start
include 'win32a.inc'
IDC_Cancel = 1
IDC_Static1 = 2
IDC_Static2 = 3
IDC_Edit1 = 4
IDC_List = 5
IDC_About = 6
IDC_Listbox1 = 7
LB_ADDSTRING = 180h
section '.data' data readable writeable
hList dd ?
hButton dd ?
about_text db 'Kompilacja FASM v1.65',0dh,0ah,'Testowanie ListBoxa',0dh,0ah,'Viki 2006',0
about_caption db 'About',0
priz db 0
roo db '?:\',0
buffer db 40 dup(0)
typ0 db '',0
typ1 db '',0
typ2 db ' stacja dyskietek',0
typ3 db ' dysk twady',0
typ4 db ' dysk sieciowy',0
typ5 db ' cd-rom',0
typ6 db ' ram dysk',0
index dd typ0
dd typ1
dd typ2
dd typ3
dd typ4
dd typ5
dd typ6
client RECT
section '.code' code readable executable
start:
invoke GetModuleHandle,0
invoke DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
or eax,eax
jz exit
exit:
invoke ExitProcess,0
;-------------------------------------------------------------------------
proc DialogProc hwnddlg,msg,wparam,lparam
;-------------------------------------------------------------------------
push ebx esi edi
cmp [msg],WM_INITDIALOG
je wminitdialog
cmp [msg],WM_SIZE
je wmsize
cmp [msg],WM_COMMAND
je wmcommand
cmp [msg],WM_CLOSE
je wmclose
xor eax,eax
jmp finish
wminitdialog:
invoke GetDlgItem, [hwnddlg],IDC_Listbox1
mov [hList],eax
invoke GetDlgItem, [hwnddlg],IDC_List
mov [hButton],eax
invoke GetClientRect,[hwnddlg],client
mov eax,[client.bottom]
sub eax,30
invoke MoveWindow,[hList],[client.left],[client.top],[client.right],eax,TRUE
mov eax,[client.right]
sub eax,82
mov [client.right],eax
mov eax,[client.bottom]
sub eax,27
invoke MoveWindow,[hButton],[client.right],eax,80,25,TRUE
xor eax,eax
jmp processed
wmsize:
invoke GetClientRect,[hwnddlg],client
mov eax,[client.bottom]
sub eax,30
invoke MoveWindow,[hList],[client.left],[client.top],[client.right],eax,TRUE
mov eax,[client.right]
sub eax,82
mov [client.right],eax
mov eax,[client.bottom]
sub eax,27
invoke MoveWindow,[hButton],[client.right],eax,80,25,TRUE
xor eax,eax
jmp processed
wmcommand:
cmp [wparam],BN_CLICKED shl 16 + IDC_Cancel
je wmclose
cmp [wparam],BN_CLICKED shl 16 + IDC_List
je addtolist
cmp [wparam],BN_CLICKED shl 16 + IDC_About
je showinfo
jmp processed
showinfo:
invoke MessageBox,[hwnddlg],about_text,about_caption,MB_OK
jmp processed
addtolist:
mov ecx, 'A'
loo:
push ecx
mov [roo], cl
invoke GetDriveType,roo
cmp [priz], 0
jz _all
cmp eax, 2
jb l3
_all:
shl eax,2
push eax
invoke lstrcpy,buffer,roo
pop ebx
invoke lstrcat,buffer,[ebx+index]
invoke SendDlgItemMessage,[ebp+08h],IDC_Listbox1,LB_ADDSTRING,0,buffer
l3:
pop ecx
inc ecx
cmp ecx, 91
jne loo
jmp processed
wmclose:
invoke EndDialog,[hwnddlg],0
processed:
mov eax,1
finish:
pop edi esi ebx
ret
endp
section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',user32,'USER32.DLL',comdlg32,'COMDLG32.dll'
include '\apia\kernel32.inc'
include '\apia\user32.inc'
include '\apia\comdlg32.inc'
section '.rsrc' resource data readable
directory RT_DIALOG,dialogs
resource dialogs,37,LANG_TURKISH+SUBLANG_DEFAULT,demonstration
dialog demonstration,'Devices list',100,100,185,175,WS_CAPTION+WS_POPUP+WS_SYSMENU+WS_SIZEBOX
;dialogitem 'BUTTON','Cancel',IDC_Cancel,130,156,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
;dialogitem 'BUTTON','About',IDC_About,80,156,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
;dialogitem 'STATIC','Press "List" button to add',IDC_Static1,10,10,200,8,WS_VISIBLE
;dialogitem 'STATIC','all devices to the listbox.',IDC_Static2,10,18,200,8,WS_VISIBLE
dialogitem 'LISTBOX',NULL,IDC_Listbox1, 10, 30, 165, 100, WS_VISIBLE+WS_BORDER+WS_VSCROLL
;dialogitem 'EDIT','',IDC_Edit1,10,120,165,13,WS_VISIBLE+WS_BORDER+WS_TABSTOP
dialogitem 'BUTTON','List',IDC_List,130,140,45,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
enddialog