EOF forum

You are not logged in.

#1 2008-06-27 04:49:29

The Shadow
Member
Registered: 2008-02-02
Posts: 10

[MASM]Knowing file sizes

Code:

include \masm32\include\masm32rt.inc               ;mem models, libraries, includes
    .data
      fname DB "\masm32\include\windows.inc",0     ;target file
    .code
start:
    call main                           ; call to proc
    inkey                                          ; wait for user
    exit                                           ; end
main proc
    LOCAL bytecount :DWORD                         ; stablish a local var
    .if rv(exist,ADDR fname) != 0                  ; test if file exist
      mov bytecount, rv(filesize,ADDR fname)       ; use the filesize proc and result is in bytecount
      print "Tama?o de WINDOWS.INC = "
      print str$(bytecount)," bytes",13,10         ;shows the result
    .else
      print "ERROR, file doesnt exist",13,10   
    .endif
    ret                           ; return
main endp
end start

enjoy

Offline

 

#2 2010-01-19 00:09:24

kazdax
Member
Registered: 2010-01-16
Posts: 2

Re: [MASM]Knowing file sizes

I dont know if it is still relevent ..thou there are other ways .. using the dos interrupt to get the file size ..

basiclly you open a file .. and get a file handle and then tell it to move from the beginning of the file to the end

and calculate beginning - end and get how large the file is ..

I think DOS interrupts still work on windows XP ..dont know about vista and 7

Offline

 

Board footer