黑基网 首页 学院 网络安全 查看内容

无声息格式化磁盘的API,VB版

2009-9-7 10:00| 投稿: security

摘要: 无声息格式化磁盘的API,VB版,使用方法: doFormat("E:") 曾经用这API做了个小恶软,专格式化U盘,代码在这里就不予公开了~~~ Public Declare Function Fo...
无声息格式化磁盘的API,VB版,使用方法: doFormat("E:") 曾经用这API做了个小恶软,专格式化U盘,代码在这里就不予公开了~~~ Public Declare Function FormatEx Lib "FMIFS.DLL" _ (DriveRoot As Any, _ ByVal MediaFlag As Long, _ Format As Any, _ Label As Any, _ ByVal QuickFormat As Long, _ ByVal ClusterSize As Long, _ ByVal Callback As Long) As Long Public Const FMIFS_HARDDISK = &HC Public Const FMIFS_FLOPPY = &H8 Public Const FMIFS_SizeDefault = 0 Public Const FMIFS_Size512 = 512 Public Const FMIFS_Size1K = 1024 Public Const FMIFS_Size2K = 2048 Public Const FMIFS_Size4K = 4096 Public Const FMIFS_Size8K = 8192 Public Const FMIFS_Size16K = 16384 Public Const FMIFS_Size32K = 32768 Public Const FMIFS_Size64K = 65536 Public Const FMIFS_Size128K = 131072 Public Const FMIFS_Size256K = 262144 Public Const FMIFS_Progress = 0 Public Const FMIFS_DoneWithStructure = 1 Public Const FMIFS_InsufficientRights = 6 Public Const FMIFS_WriteProtected = 7 Public Const FMIFS_Done = 11 Public Const FMIFS_OutPut = 14 Public Const FMIFS_StructureProgress = 15 Public gbytResult As Byte Function doFormat(sDriveLetter As String) As Boolean On Error Resume Next Dim bytDrive() As Byte Dim bytFS() As Byte Dim bytLabel() As Byte bytDrive = sDriveLetter & Chr$(0) bytFS = "FAT" & Chr$(0) bytLabel = GetDriveVol(sDriveLetter) & Chr$(0) Call FormatEx(bytDrive(0), _ FMIFS_HARDDISK, _ bytFS(0), _ bytLabel(0), _ 0, _ FMIFS_SizeDefault, _ AddressOf FormatexCallBack) If gbytResult = 1 Then doFormat = True Else doFormat = False End If End Function Public Function FormatexCallBack(ByVal lngCommand As Long, ByVal lngSubAction As Long, ByVal ActionInfo As Long) As Long On Error Resume Next Dim lngInfo As Long Dim bytMessage(256) As Byte Select Case lngCommand Case FMIFS_Progress DoEvents Case FMIFS_DoneWithStructure DoEvents Case FMIFS_InsufficientRights DoEvents Case FMIFS_WriteProtected DoEvents Case FMIFS_Done Call CopyMemory(gbytResult, ByVal ActionInfo, 1) DoEvents Case FMIFS_OutPut DoEvents Case FMIFS_StructureProgress DoEvents End Select FormatexCallBack = 1 End Function
小编推荐:欲学习电脑技术、系统维护、网络管理、编程开发和安全攻防等高端IT技术,请 点击这里 注册黑基账号,公开课频道价值万元IT培训教程免费学,让您少走弯路、事半功倍,好工作升职加薪!



免责声明:本文由投稿者转载自互联网,版权归原作者所有,文中所述不代表本站观点,若有侵权或转载等不当之处请联系我们处理,让我们一起为维护良好的互联网秩序而努力!联系方式见网站首页右下角。


鲜花

握手

雷人

路过

鸡蛋

相关阅读

最新评论


新出炉

返回顶部