Solved

C++ Language question

Posted on 1997-07-09
2
363 Views
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.
thanks.
0
Comment
Question by:matchz
2 Comments
 
LVL 3

Accepted Solution

by:
LucHoltkamp earned 40 total points
Comment Utility
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:

DEVICEPARAMS STRUC
 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      
DEVICEPARAMS ENDS

return in ax in case of error (carry set on return from OS):
 01h     ; ERROR_INVALID_FUNCTION
 02h     ; ERROR_FILE_NOT_FOUND
 05h     ; ERROR_ACCESS_DENIED

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

.luc.
0
 

Author Comment

by:matchz
Comment Utility
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?
thanks.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

743 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

15 Experts available now in Live!

Get 1:1 Help Now