Clarion Advisor - Drive Free Space

by Rob Cohan

Published 1999-07-06    Printer-friendly version

Courtesy Of TS Resources Inc.

If you've ever needed to determine how much free space there is on a drive, and you're doing 32 bit development, you'll want to get the freeware drive freespace dll from TS Resources Inc. (Rob Cohan).

This is a C language DLL which can be called by Clarion 32 bit applications, and which returns accurate disk free space figures for all 32 bit Microsoft Windows operating systems. It uses internal dynamic linkage to avoid the problems associated with statically linking the accurate, advanced functions which are not available in the original releases of Windows 95.

To use this DLL in your application choose Application|Insert Module from the main menu, and select a module of type ExternalLib (External Library Module). Fill in the Name and Map Include File fields as shown in Figure 1. The spc.mif file contains the prototype for the spc function.

Figure 1. The CWSPC module properties.

freespace_fig1.gif (4594 bytes)

The zip file contains an example application.

The spc function usage is straightforward

result = spc( cstring *DriveLetter, long Mode )

Driveletter is a cstring of at least two bytes length (one character plus the requisite terminating NULL character space.)

Mode can be one of the following:

  • 1 for a free space call,
  • 2 for the size of the drive if empty, or
  • 3 for the presently utilized space.

Under Windows 2000, a mode of 1 is intended to get free space allocated to the present user.

spc returns a numeric cstring to allow for future variability in the size of number reported. Due to Clarion's automatic type conversions, you can use this result directly as a number in most cases, even when formatting the result, as shown in Listing 1.

Listing 1. The example application code to determine drive space.
 csDriveLetter = clip(DriveLetter)&'<0>'   !turn into cstring)
 FreeSpaceNow  = format( spc(csDriveLetter, 1), @n15)
 TabulaRasa    = format( spc(csDriveLetter, 2), @n15)
 Utilized      = format( spc(csDriveLetter, 3), @n15)

Many thanks to TS Resources Inc. for making this utility available!

Download the dll and example application.

Printer-friendly version

Reader Comments

Posted on Tuesday, June 06, 2006 by Dave Harms

The download is no longer available from that site, but there is another article by Andrew Guidroz which shows how to get drive free space: http://www.clarionmag.com/cmag/v6/v6n05drivetype.html

To add a comment to this article you must log in.

 
 

Search

 

Advanced Search
Topical Index

Related Articles

Subscribe to
ClarionMag

One year: $189

(includes all back issues since '99)

Renewals from $139

Two years: $289

Renewals from $239

More Info

Subscribe Now!

ClarionMag Blog

RSS Feeds

Updates via Email

Enter your Email


Powered by FeedBlitz

Quick Links