C++ Language question

Posted on 1997-07-09
Last Modified: 2008-03-17
In Dos, i can using getdfree() or similar function to read a FAT16 information such as cluster size... however, the function will not work if the HD is formatted as FAT32.
how to due with the problems.
Question by:matchz

Accepted Solution

LucHoltkamp earned 40 total points
ID: 1164605
Use a decent compiler, or at least one that fully supports Win32. Borland C++ 5.0 did it right with both the Win32 Console target and the Dos16 target.

The OS handles the call correctly, but the older RTL's may misinterpret the data returned by the OS. Try Dos INT 21h, function 440Dh, minor code 60h ("GetDeviceParameters") (See your DOS programmers Reference, you do have it, don't you ?? :) )

Assembly Example:

  mov bx, Drive          ;  0 = default, 1 = A, 2 = B, etc
  mov ch, 08h            ; device category (must be 08h)
  mov cl, 60h            ; minor code: "get device parameters"
  mov dx, seg DriveDP    ;
  mov ds, dx             ;
  mov ds, offset DriveDP ;ds:dx points to DEVICEPARAMS structure
  mov ax, 440Dh          ;function 440Dh: IOCTL for Block Device
  int 21h                ; call OS
  jc  error_handler      ; carry set means error, errorcode in AX

DriveDP Points to a DEVICEPARAMS structure that receives the information from the OS:

 dpSpecFunc     db ?  ; special functions
 dpDevType      db ?  ; device type
 dpDevAttr      dw ?  ; device attributes
 dpCylinders    dw ?  ; number of cylinders
 dpMediaType    db ?  ; media type
 ; Start of Bios Parameter Block
 dpBytesPerSec  dw ?  ; bytes per sector
 dpSecPerClust  db ?  ; sectors per cluster
 dpResSectors   dw ?  ; number of reserved sectors
 dpFATs         db ?  ; number of FAT's
 dpRootDirEnts  dw ?  ; number of rootdirectory entries
 dpSector       dw ?  ; total number of sectors
 dpMedia        db ?  ; media descriptor
 dpFATsecs      dw ?  ; number of sectors per FAT
 dpSecPerTrack  dw ?  ; number of sector per Track
 dpHeads        dw ?  ; number of heads
 dpHiddenSecs   dd ?  ; number of hidden sectors
 dpHugeSectors  dd ? ; number of sectors if dpSectors == 0
 ; End of BIOS parameter block      

return in ax in case of error (carry set on return from OS):

Get Device Parameters returns 0002h (ERROR_FILE_NOT_FOUND) if the specified drive number is invalid.


Author Comment

ID: 1164606
Thanks you for your answer.
but i am sorry that i don't know what's the mean of RTL.
Would you explain for it.
also, other than using Dos interrupt, any borland c++ provide function of method (not in asm) can handle the question?

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 72
TTimer no longer functioning 7 90
SNMP error No Such Object available on this agent at this OID 3 247
Unresolved External Symbols 3 81
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

776 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