?
Solved

Read and Writing disk throught c++/vc++

Posted on 2004-09-22
4
Medium Priority
?
310 Views
Last Modified: 2010-04-17
hello experts
             I want to know how i can read the hard disk sectors/clustors and
                           i) write then in a buffer
                           ii) write then on another hard disk
                           iii) write then in a file.
plz help me by giving c++/vc++ code examples so that i will understand how these all cases will done programmatically.

With best regards
kamboj
0
Comment
Question by:stellarguy
2 Comments
 
LVL 3

Accepted Solution

by:
PodExpert earned 1000 total points
ID: 12120678
Dear kamboj,
the answer to your question is strongly OS-dependent. It seems that you are talking about Win32 system, then try to read the following article:

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q100/0/27.asp&NoWebContent=1

It contains almost everything you need to perform direct disk access. However, I think that Windows NT, 2000 or XP won't let you write to your system drive directly, unless you would act with SYSTEM privilleges.

Regards.
P.
0
 
LVL 3

Assisted Solution

by:sathisemail
sathisemail earned 1000 total points
ID: 12131254
In C you can use the biosdisk function to read or write to the disk. The same can also be used in C++. C++ doesn't provide any special functions (as far as i know), since you can use the C function itself.

The biosdisk function reads the disk in 512byte chunks and store it in the array you specified. Similarly it also writes to the disk in 512 byte chunks.

The biosdisk reads the 512byte from the sector which is passed to it as a parameter and write then in a buffer.
You can use the biosdisk funtion to write on another hard disk which is also by setting the parameter
The read bytes are stored in a character array which is then can be easily written to a file. you can see an example program

http://www.geocities.com/progguru/Absrw.html
http://www.programmershelp.co.uk/cbiosdisk.php


It is some what harder in the case of windows environment because of its protected environment. But you can get a good idea of how to directly acces the hard disk using VC++ from the link given below. It provides you with a detailed information about the structure and how to get the information using the dll's provided along with the windows.

http://www.codeguru.com/Cpp/W-P/system/hardwareinformation/article.php/c5705/

Regards
Sathis.
0

Featured Post

Industry Leaders: 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

Make the most of your online learning experience.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Introduction to Processes
Loops Section Overview

850 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