Solved

C++ Language question

Posted on 1997-07-09
2
379 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

Technology Partners: 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

Suggested Solutions

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

734 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