Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What is Python programming? 3 66
Counting documents in a Domino View 3 36
recursion example 16 68
C# Error - Add Failed 12 39
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A short article about problems I had with the new location API and permissions in Marshmallow
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

19 Experts available now in Live!

Get 1:1 Help Now