Solved

How to get BytesPerCluster?

Posted on 1998-08-06
8
211 Views
Last Modified: 2013-12-03
Hi,

Here's the way I get the BytesPerCluster in my freeware to caculate disk allocation.

      if(GetDiskFreeSpace(szCurrDir,
            &dwSectorsPerCluster, &dwBytesPerSector,
            &dwFreeClusters, &dwClusters))
            dwBytesPerCluster = dwSectorsPerCluster*dwBytesPerSector;

One of my user, apparently knows better windows than me, point out that the figure I got (32k) is wrong:

> "On the latest Win95, OSR 2, and Win98 operating systems, FAT32 allows 4 KB clusters for large HD's between 2 GB to 2 TB size. "

I've notice that the figure I got is wired already, and it is not correct also on Novell. So I want to know, how to get it through VC? Thanks
0
Comment
Question by:tsun
  • 5
  • 3
8 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1413194
Windows 95 OSR 2: The GetDiskFreeSpaceEx function is available on Windows 95 systems beginning with OEM Service Release 2 (OSR 2). The GetDiskFreeSpaceEx function returns correct values for all volumes, including those that are greater than 2 gigabytes.

But it does not return the value you want.

You need to use Int 21h Function 7303h Get_ExtFreeSpace (FAT32). It returns the following structure implemented in Windows OEM Service Release 2 and later.

ExtGetDskFreSpcStruc STRUC
    ExtFree_Size                      DW    ?
    ExtFree_Level                     DW    ?
    ExtFree_SectorsPerCluster         DD    ?
    ExtFree_BytesPerSector            DD    ?
    ExtFree_AvailableClusters         DD    ?
    ExtFree_TotalClusters             DD    ?
    ExtFree_AvailablePhysSectors      DD    ?
    ExtFree_TotalPhysSectors          DD    ?
    ExtFree_AvailableAllocationUnits  DD    ?
    ExtFree_TotalAllocationUnits      DD    ?
    ExtFree_Rsvd                      DD    2 DUP (?)
ExtGetDskFreSpcStruc ENDS

See the Platform SDK documentation for how to call it.

Platform SDK\Windows Base Services\Windows 95 Features\Using Windows 95 Features\FAT32 File System

Platform SDK\Windows Base Services\Windows 95 Features\Using Windows 95 Features\Windows 95 Reference\FAT32 API Reference
0
 

Author Comment

by:tsun
ID: 1413195
Wow! You're really a genius.

I'd like to ask just one more question before I close my question: It seems I have to treate differently with different disks, at least Novell doesn't support Int 21h Function 7303h, right? Anything else should be take into account?

Any suggestions? (It doesn't affect how I grade your score if you don't, :-) )


0
 
LVL 23

Expert Comment

by:chensu
ID: 1413196
>It seems I have to treate differently with different disks, at least Novell doesn't support Int 21h Function 7303h, right?

Yes, you're right.

>Anything else should be take into account? Any suggestions?

If you are going to support NTFS in your Windows NT application, you can get more information about NTFS. See http://www.sysinternals.com/ntfsinfo.htm.

0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:tsun
ID: 1413197
Wow! You're really a genius.

I'd like to ask just one more question before I close my question: It seems I have to treate differently with different disks, at least Novell doesn't support Int 21h Function 7303h, right? Anything else should be take into account?

Any suggestions? (It doesn't affect how I grade your score if you don't, :-) )


0
 
LVL 23

Expert Comment

by:chensu
ID: 1413198
>It seems I have to treate differently with different disks, at least Novell doesn't support Int 21h Function 7303h, right?

Yes, you're right.

>Anything else should be take into account? Any suggestions?

If you are going to support NTFS in your Windows NT application, you can get more information about NTFS. See http://www.sysinternals.com/ntfsinfo.htm.

0
 

Author Comment

by:tsun
ID: 1413199
Wow! You're really a genius.

I'd like to ask just one more question before I close my question: It seems I have to treate differently with different disks, at least Novell doesn't support Int 21h Function 7303h, right? Anything else should be take into account?

Any suggestions? (It doesn't affect how I grade your score if you don't, :-) )


0
 

Author Comment

by:tsun
ID: 1413200
OK, Thanks very much!
0
 

Author Comment

by:tsun
ID: 1413201
OK, Thanks very much!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question