Solved

How to get BytesPerCluster?

Posted on 1998-08-06
8
206 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now