Solved

Format a Hard disk Partition with c#

Posted on 2003-11-16
4
6,064 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
[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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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