Get progress from scanning - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Get progress from scanning

anggianggi Posts: 3Member
I am trying to make simple malware removal, but I dont know how to get the percentage of path that I want to scan. For example I scan c:folder, I want to get the percentage to make progress bar while scanning.

Thx a lot.

Comments

  • AtexAtex Posts: 268Member
    Let be [b]m[/b] the total number of files in a folder, [b]n[/b] the current file you process (a nonzero number) then current percentage ([b]cp[/b]) would be: [b]cp:=n*100/m[/b]
  • anggianggi Posts: 3Member
    How can I get m ? Do I have to scan twice? :(
  • AtexAtex Posts: 268Member
    : How can I get m ? Do I have to scan twice? :(

    No, you have to use the [b]findfirst[/b] and [b]findnext[/b] procedures from the [b]Dos[/b] unit to get all the filenames in a folder first. That gives you the [b]m[/b]. When you scan you'll have to open each file for scan, starting from 1 ([b]n[/b]).
  • anggianggi Posts: 3Member
    If I use findfirst or findnext, that will wasting time???
  • AtexAtex Posts: 268Member
    : If I use findfirst or findnext, that will wasting time???

    No time wasting there (takes only a fraction of a second), beside that's the only way to find out the file names from a folder...unless you read the FAT directly and process the info but that's a bit beyond plain Pascal's capability, you'd have to rely on assembly there...

Sign In or Register to comment.