在程序中如何格式化软盘

解决方案 »

  1.   

    这里有详细说明。
    http://www.vckbase.com/bbs/prime/viewprime.asp?id=322
      

  2.   

    这里有详细说明。
    http://www.vckbase.com/bbs/prime/viewprime.asp?id=322
      

  3.   

    使用
    DWORD WINAPI SHFormatDrive(HWND hwnd,
                                  UINT drive,
                                  UINT fmtID,
                                  UINT options);
    这里有详细说明。
    http://www.vckbase.com/bbs/prime/viewprime.asp?id=322
      

  4.   

    Win9X软盘编辑 
    周化 2000-06-10 
    下载示范代码40K  http://www.copathway.com/vchelp/zsrc/winbiosdisk.zip我早期有个Win9x下软盘编辑的演示程序,我现将其源代码公开,我使用的是API编程,可格式化、校验和读写特殊扇区。可用作Windows下的磁盘加密。  软盘扇区绝对读取函数  WinBiosDisk()  

    作者: 周化     编译平台: Virusal C++ 6.0 为了方便, 本函数的参数设计得同 Turbo C 2.0 的 biosdisk() 函数一样. 本函数还有以下两个缺点以待改进:
    1.本函数还只能读能读 A: 和 B:,即只能对软盘操作
    2.不能改变磁盘扇区大小,只能是标准的 512 个字节。 参数说明:
    command        操作: 
    0    重置磁盘
    2    读扇区
    3    写扇区
    4    校验磁道
    5    格式化磁道
    8    得到设备参数 (int 1EH)
    drive          驱动器 A:=0 B:=1
    head           磁头号,范围 0 - 1
    track          磁道号,范围 0 - 84    ( 80 - 84  为特殊磁道,通常用来加密 )
    sector         扇区号,范围 0 - 255   ( 19 - 255 为非标准扇区编号,通常用来加密) 
    nsectors       每次读或写的扇区数,不能超出每磁道的最大扇区数 
    buffer         数据写入或读出的缓冲区,大小为 512 个字节 返回值 ( 同 Int 13H ):
    0x0     成功
    0x1     无效的命令
    0x3     磁盘被写保护
    0x4     扇区没有找到
    0xa     发现坏扇区
    0x80    磁盘没有准备好 
      

  5.   

    Win9X软盘编辑 
    周化 2000-06-10 
    下载示范代码40K  http://www.copathway.com/vchelp/zsrc/winbiosdisk.zip我早期有个Win9x下软盘编辑的演示程序,我现将其源代码公开,我使用的是API编程,可格式化、校验和读写特殊扇区。可用作Windows下的磁盘加密。  软盘扇区绝对读取函数  WinBiosDisk()  

    作者: 周化     编译平台: Virusal C++ 6.0 为了方便, 本函数的参数设计得同 Turbo C 2.0 的 biosdisk() 函数一样. 本函数还有以下两个缺点以待改进:
    1.本函数还只能读能读 A: 和 B:,即只能对软盘操作
    2.不能改变磁盘扇区大小,只能是标准的 512 个字节。 参数说明:
    command        操作: 
    0    重置磁盘
    2    读扇区
    3    写扇区
    4    校验磁道
    5    格式化磁道
    8    得到设备参数 (int 1EH)
    drive          驱动器 A:=0 B:=1
    head           磁头号,范围 0 - 1
    track          磁道号,范围 0 - 84    ( 80 - 84  为特殊磁道,通常用来加密 )
    sector         扇区号,范围 0 - 255   ( 19 - 255 为非标准扇区编号,通常用来加密) 
    nsectors       每次读或写的扇区数,不能超出每磁道的最大扇区数 
    buffer         数据写入或读出的缓冲区,大小为 512 个字节 返回值 ( 同 Int 13H ):
    0x0     成功
    0x1     无效的命令
    0x3     磁盘被写保护
    0x4     扇区没有找到
    0xa     发现坏扇区
    0x80    磁盘没有准备好 
      

  6.   

    //use SHFormatDrive method
     /*****************************************************************
       The SHFormatDrive API provides access to the Shell's format
       dialog box. This allows applications that want to format disks to bring
       up the same dialog box that the Shell uses for disk formatting.   PARAMETERS
          hwnd    = The window handle of the window that will own the
                    dialog. NOTE that hwnd == NULL does not cause this
                    dialog to come up as a "top level application"
                    window. This parameter should always be non-null,
                    this dialog box is only designed to be the child of
                    another window, not a stand-alone application.      drive   = The 0 based (A: == 0) drive number of the drive
                    to format.      fmtID   = Currently must be set to SHFMT_ID_DEFAULT.      options = There are currently only two option bits defined.                   SHFMT_OPT_FULL
                       SHFMT_OPT_SYSONLY                SHFMT_OPT_FULL specifies that the "Quick Format"
                    setting should be cleared by default. If the user
                    leaves the "Quick Format" setting cleared, then a
                    full format will be applied (this is useful for
                    users that detect "unformatted" disks and want
                    to bring up the format dialog box).                If options is set to zero (0), then the "Quick Format"
                    setting is set by default. In addition, if the user leaves
                    it set, a quick format is performed. Under Windows NT 4.0,
                    this flag is ignored and the "Quick Format" box is always
                    checked when the dialog box first appears. The user can
                    still change it. This is by design.                The SHFMT_OPT_SYSONLY initializes the dialog to
                    default to just sys the disk.                All other bits are reserved for future expansion
                    and must be 0.                Please note that this is a bit field and not a
                    value, treat it accordingly.      RETURN
             The return is either one of the SHFMT_* values, or if
             the returned DWORD value is not == to one of these
             values, then the return is the physical format ID of the
             last successful format. The LOWORD of this value can be
             passed on subsequent calls as the fmtID parameter to
             "format the same type you did last time".   *****************************************************************/ 
       DWORD WINAPI SHFormatDrive(HWND hwnd,
                                  UINT drive,
                                  UINT fmtID,
                                  UINT options);   // 
       // Special value of fmtID which means "use the defaultformat"
       //    #define SHFMT_ID_DEFAULT   0xFFFF   // 
       // Option bits for options parameter
       //    #define SHFMT_OPT_FULL     0x0001
       #define SHFMT_OPT_SYSONLY  0x0002   // 
       // Special return values. PLEASE NOTE that these are DWORD values.
       //    #define SHFMT_ERROR     0xFFFFFFFFL    // Error on last format,
                                              // drive may be formatable
       #define SHFMT_CANCEL    0xFFFFFFFEL    // Last format wascanceled
       #define SHFMT_NOFORMAT  0xFFFFFFFDL    // Drive is not formatable   #if defined (__cplusplus)
       }
       #endif
       #endif //End:Begin
    //sample code
    DWORD ret=SHFormatDrive(this->m_hWnd,0/*A:*/, SHFMT_ID_DEFAULT,SHFMT_OPT_FULL|SHFMT_OPT_SYSONLY);
      

  7.   

    //use SHFormatDrive method
     /*****************************************************************
       The SHFormatDrive API provides access to the Shell's format
       dialog box. This allows applications that want to format disks to bring
       up the same dialog box that the Shell uses for disk formatting.   PARAMETERS
          hwnd    = The window handle of the window that will own the
                    dialog. NOTE that hwnd == NULL does not cause this
                    dialog to come up as a "top level application"
                    window. This parameter should always be non-null,
                    this dialog box is only designed to be the child of
                    another window, not a stand-alone application.      drive   = The 0 based (A: == 0) drive number of the drive
                    to format.      fmtID   = Currently must be set to SHFMT_ID_DEFAULT.      options = There are currently only two option bits defined.                   SHFMT_OPT_FULL
                       SHFMT_OPT_SYSONLY                SHFMT_OPT_FULL specifies that the "Quick Format"
                    setting should be cleared by default. If the user
                    leaves the "Quick Format" setting cleared, then a
                    full format will be applied (this is useful for
                    users that detect "unformatted" disks and want
                    to bring up the format dialog box).                If options is set to zero (0), then the "Quick Format"
                    setting is set by default. In addition, if the user leaves
                    it set, a quick format is performed. Under Windows NT 4.0,
                    this flag is ignored and the "Quick Format" box is always
                    checked when the dialog box first appears. The user can
                    still change it. This is by design.                The SHFMT_OPT_SYSONLY initializes the dialog to
                    default to just sys the disk.                All other bits are reserved for future expansion
                    and must be 0.                Please note that this is a bit field and not a
                    value, treat it accordingly.      RETURN
             The return is either one of the SHFMT_* values, or if
             the returned DWORD value is not == to one of these
             values, then the return is the physical format ID of the
             last successful format. The LOWORD of this value can be
             passed on subsequent calls as the fmtID parameter to
             "format the same type you did last time".   *****************************************************************/ 
       DWORD WINAPI SHFormatDrive(HWND hwnd,
                                  UINT drive,
                                  UINT fmtID,
                                  UINT options);   // 
       // Special value of fmtID which means "use the defaultformat"
       //    #define SHFMT_ID_DEFAULT   0xFFFF   // 
       // Option bits for options parameter
       //    #define SHFMT_OPT_FULL     0x0001
       #define SHFMT_OPT_SYSONLY  0x0002   // 
       // Special return values. PLEASE NOTE that these are DWORD values.
       //    #define SHFMT_ERROR     0xFFFFFFFFL    // Error on last format,
                                              // drive may be formatable
       #define SHFMT_CANCEL    0xFFFFFFFEL    // Last format wascanceled
       #define SHFMT_NOFORMAT  0xFFFFFFFDL    // Drive is not formatable   #if defined (__cplusplus)
       }
       #endif
       #endif //End:Begin
    //sample code
    DWORD ret=SHFormatDrive(this->m_hWnd,0/*A:*/, SHFMT_ID_DEFAULT,SHFMT_OPT_FULL|SHFMT_OPT_SYSONLY);
      

  8.   

    Win9X软盘编辑 
    周化 2000-06-10 
    下载示范代码40K  http://www.copathway.com/vchelp/zsrc/winbiosdisk.zip我早期有个Win9x下软盘编辑的演示程序,我现将其源代码公开,我使用的是API编程,可格式化、校验和读写特殊扇区。可用作Windows下的磁盘加密。  软盘扇区绝对读取函数  WinBiosDisk()  

    作者: 周化     编译平台: Virusal C++ 6.0 为了方便, 本函数的参数设计得同 Turbo C 2.0 的 biosdisk() 函数一样. 本函数还有以下两个缺点以待改进:
    1.本函数还只能读能读 A: 和 B:,即只能对软盘操作
    2.不能改变磁盘扇区大小,只能是标准的 512 个字节。 参数说明:
    command        操作: 
    0    重置磁盘
    2    读扇区
    3    写扇区
    4    校验磁道
    5    格式化磁道
    8    得到设备参数 (int 1EH)
    drive          驱动器 A:=0 B:=1
    head           磁头号,范围 0 - 1
    track          磁道号,范围 0 - 84    ( 80 - 84  为特殊磁道,通常用来加密 )
    sector         扇区号,范围 0 - 255   ( 19 - 255 为非标准扇区编号,通常用来加密) 
    nsectors       每次读或写的扇区数,不能超出每磁道的最大扇区数 
    buffer         数据写入或读出的缓冲区,大小为 512 个字节 返回值 ( 同 Int 13H ):
    0x0     成功
    0x1     无效的命令
    0x3     磁盘被写保护
    0x4     扇区没有找到
    0xa     发现坏扇区
    0x80    磁盘没有准备好