?
Solved

C++ Language question

Posted on 1997-07-09
2
Medium Priority
?
381 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 80 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

770 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