Solved

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

Posted on 2004-09-22
4
280 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
4 Comments
 
LVL 3

Accepted Solution

by:
PodExpert earned 250 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 250 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groovy example issue 10 97
C Programming - If Statement 8 76
Basic Java Case or If-Else statement... 3 50
iSeries email authority 6 56
A short article about a problem I had getting the GPS LocationListener working.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

786 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