I work in C,C++ Windows platform. I am to write code to format a pendrive. I searched and found DeviceIOControl() that seemed to fulfill my purpose. But I cannot proceed any further. Plz help me in this regard.


Recommended Answers

All 3 Replies

Did you try this shell API SHFormatDrive . It is the simplest one.
There is not other documented API apart from SHFormatDrive(). Only drawback is it is interactive.
If you do not want user to interact and you are targetting Wk3 you can use WMI classes
see this. You can find a C++ example as well there.

Firstly Thanx
I have seen that API. But I have been told not to use that and do the entire coding by myself. I used CreateFile() and have got the disk handle. But I frnkly cannot make out what to do with the handle now.PLz do suggest some alternatives...

Formatting a drive is not a small task if you do not want to use WMI and shell APIs.
You will have to understand the basics of NTFS or FAT(which ever you select).
There are tons of resources on Internet. However, is is not an atomic task...


I don't know any simple way to format easisly. As I have told you earlier there are no as such documented APIs which can do formetting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.