Desktop Functions: Smart Device Functions:
|
SHFormatDrive (shell32)
C# Signature:
[DllImport("shell32.dll")] User-Defined Types:
public enum SHFormatFlags : uint { Notes:The hwnd field should be the handle of the required parent calling window (see http://msdn.microsoft.com/en-us/library/bb762169.aspx). passing in <parent window>.Handle (in C#) works in XP, but in Vista it does not. What works on Vista is passing in 0 (IntPtr.Zero). I have tested this on WP SP2 and it works there as well. The fmtID field should always be passed SHFMT_ID_DEFAULT. The drive field should denote the numerical listing of the drive letter to be formatted. (Ex: A is 0, Z is 25) The options field should be 0 for a full disk format, pass SHFMT_OPT_FULL for a Quick Format, or set SHFMT_OPT_SYSONLY to create an MS-DOS System Boot Disk. The function will return the ID of the last successful format, or one of the following error codes: - SHFMT_ERROR: A general error occured while formatting. This is not an indication that the drive cannot be formatted though. - SHFMT_CANCEL: The drive format was cancelled by user/OS. - SHFMT_NOFORMAT: A serious error occured while formatting. The drive is unable to be formatted by the OS. Tips & Tricks:Please add some! Sample Code:C# Sample Call:
uint result = SHFormatDrive( this.Handle, NOTE- See the Note above about the hwnd field and Vista. Use
SHFormatDrive( IntPtr.Zero, On Vista and better, you also have the Win32_Volume WMI classes. Alternative Managed API:Do you know one? Please contribute it! Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|