DiskSpace Tracker

This project is made with MS Visual C++ Version 6.0 with the latest Service Pack and tested on Windows NT 4.0 Workstation SP4.

For a Setup I'm writing I wanted to know how much diskspace would be needed for the setup of some components. My Setup installs Internet Explorer, Microsoft Data Access Components, DAO and the Windows 95 Euro Update (nice isn't it?  I say now when it's almost done <g>).

During those setups, mostly from Microsoft, all sorts of things happen on the drive(s). Often there is need for additional diskspace for temporary files. I wanted to track the disk usage during those install procedures. That should also be possible over a network connection. When I searched the docs for stuff to do this with I found this:

BOOL GetDiskFreeSpaceEx(LPCTSTR lpDirectoryName,                      // pointer to the directory name
                        PULARGE_INTEGER lpFreeBytesAvailableToCaller, // receives the number of bytes on disk
                                                                      //   available to the caller
                        PULARGE_INTEGER lpTotalNumberOfBytes          // receives the number of bytes on disk
                        PULARGE_INTEGER lpTotalNumberOfFreeBytes      // receives the free bytes on disk)

The function can take an UNC name as a parameter for the directory name and works under 95/98/NT/2000. I wrote a simple dialog app around it. You can see what is does by looking at the main dialog window:

DiskSpace Tracker.jpg (26445 bytes)

You can also run two instances of this program, select different drives and then watch the values change as you move data from one disk to another. Changes of UNC and Update are immediate when you move the cursor off. After clicking on Start (which then becomes Stop) the window flashes every time the values on the screen are updated.

The program demonstrates the use of 64-bit integers so you can watch how much space you have left on your new terabyte gigadisk, timerfunctions, registry access and Z-Order manipulation. The code is pretty much self-explaining, perhaps nice for a fresh starter with MSVC++, so have fun with it!

Download demo project - 18 KB



Comments

  • doubt in getfreediskspaceEx

    Posted by Legacy on 08/16/1999 12:00am

    Originally posted by: s.p.manoj


    I want to know how to convert the ULARGE_INTEGER values
    in to valuable info in the form of an DWORD data type.
    So that i can display it in an static text control,using
    setdlgitemint function.if there is any other options
    for getting the info in a rigid manner pls inform me as soon
    as possible.
    s.p.manoj

    Reply
  • Disk Space Tracker

    Posted by Legacy on 05/21/1999 12:00am

    Originally posted by: Roger L. Mcelfresh

    The math is incorrect in finding Mbytes and Gbytes, S/B divide by 1000 not 1024.
    A hard drive is rated in Giga Bytes not Mega Bytes

    Reply
  • GetDiskFreeSpaceEx on Win95

    Posted by Legacy on 05/16/1999 12:00am

    Originally posted by: arst

    GetDiskFreeSpaceEx will only work on Win95 OSR2 and better.
    For Win95, one can temporarily remap an UNC to a drive
    letter and then do GetDiskFreeSpace.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds