Solved

Format a Hard disk Partition with c#

Posted on 2003-11-16
4
5,889 Views
Last Modified: 2012-05-04
hi i want to develope a program .to do do some sort of formating partitions.and so on.is it possible to do in c#,and if yes could anyone supplay me with more info.cause may i will develop a program like partition magic with c#
0
Comment
Question by:hema_jone_mickey
4 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9762277
Check this out. It's Visual Basic but you can probably convert it to C#.
0
 
LVL 6

Accepted Solution

by:
martinv earned 30 total points
ID: 9944470
Try using SHFormatDrive API function
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shformatdrive.asp)

// C#
[DllImport("shell32.dll",
    EntryPoint="SHFormatDrive",
    CharSet=CharSet.Unicode)]
public static extern Int64
    SHFormatDrive(IntPtr hwnd,
    int drive, int fmtID,
    int options);


// C#

private void CallSHFormatDrive_Click(object sender,
    System.EventArgs e)
{
    if (NativeMethodsOrdinal.SHFormatDrive(this.Handle,
        2, SharedNativeMethods.SHFMT_ID_DEFAULT,
        (int)SharedNativeMethods.
            ShellFormatOptions.SHFMT_OPT_FULL)
        == (long)SharedNativeMethods.
            ShellFormatReturnCodes.SHFMT_CANCEL)
        MessageBox.Show("Format Canceled");
}

Code taken from http://www.duncanmackenzie.net/writing/SettlementAPIs.htm
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Contant UI messages in .NET 1 41
bulid json format 3 21
IO.FileSystemWatcher dies when used in Powershell 1 27
C# TextBox 11 15
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

759 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