tags:

views:

54

answers:

1

I am writing a application that monitor the system's health, user should know when they need to defrag the volumes.

What I am thinking is calling the "defrag.exe /A" then analyze the output result to see whether it contains "You do not need to defragment this volume."

But it's slow and very bad, I fount that the "Analyze" is really quick on the MyDefrag.exe.

Anyone could tell me what's the best and simplest way?

+1  A: 

In very general terms, you are going to have to:

  1. be able to learn what file system is used on the volume in questions
  2. read over the filesystem structures and accumulate statistics on how many files are broken up and how long the typical contiguous runs are
  3. compare the results of set 2 with some heuristics for when seek times start to get considerable in the total file reading time (choosing the heuristics requires some judgment). Note that the heuristic probably depends on the filesystem in use.

What step(s) are you having trouble with?

dmckee
Thanks dmckee, sounds like not an easy work, I thought there might be a simple Windows API like: bool needDefragOnVolume(...), I must be wrong, I will check out the source code of jkDeFrag to see what happen.
@r9r9r9: This is a medium big project, and it is very likely that if the OS provided such an API, it would also provide a default tool taking advantage of it...I don't know windows so I can't say if there is such a thing, but I know that neither Linux nor Mac OS provide this service. ('Course, they also use filesystems which have relatively little need for such tools.)
dmckee