Solved

C++ Language question

Posted on 1997-07-09
2
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
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:

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
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?
thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

724 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