Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

688 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