News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Comparing drive sizes

Started by shadow, July 08, 2005, 02:56:47 AM

Previous topic - Next topic

shadow



.data


.data?
DISKSIZE struc
   dwLowSize dd ?
   dwHighSize dd ?
DISKSIZE ends


.data?
avail_bytes DISKSIZE <>
total_bytes DISKSIZE <>
free_bytes DISKSIZE <>
file_bytes DISKSIZE <>

mainbuffer db 4000 DUP (?)
mainbuffer1 db 4000 DUP (?)

.code
invoke GetDiskFreeSpaceEx,addr mainbuffer,addr avail_bytes,addr total_bytes,addr free_bytes

;--

mov file_bytes.dwLowSize,80286480h  ; I think it works!
mov file_bytes.dwHighSize,00000004h

;--

mov eax, [avail_bytes.dwHighSize]
cmp eax, [file_bytes.dwHighSize] ;avail - file
ja enough_room
jb not_enough
mov eax, [avail_bytes.dwLowSize]
cmp eax, [file_bytes.dwLowSize] ;avail - file
jae enough_room



not_enough:
invoke MessageBox,hWin,addr smallt,addr smallc,MB_OK+MB_ICONERROR
ret

enough_room:

ret




would that work?   :wink
Windows calculator! oooh a new friend -shakes hand-  :U
thanks!

Jeff

ps.  dont forget the 'h' suffix since that is hex.  ;)

for windows calculator in scientific mode:
on the top youll see different bases (hex,dec,bin,oct).  so if you wanted to see "100" decimal as hexadecimal, make sure you are in "dec" mode, type in 100, then switch to "hex" mode.  there's your number.  also, in the non-"dec" modes, you can specify the number sizes (QWORD, DWORD,WORD,BYTE).  also digit grouping helps a lot.  play around with it, it can do some cool things.

[edit]
hehe, a lil too slow for ya.  :D

shadow

oooh  I've been using online conversion calculators :)  i'll add the h's

Mark Jones

One last little quirk about numbers in MASM - any hex number must start with a 0 and end with an H. Thus, something like this would generate an error: MOV EAX,EFF20H
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08