Solved

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

Posted on 2004-09-22
4
271 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now