Program floppy disk is a common carrier of data, our software may provide users to backup data to the floppy disk function. The safest way to avoid having a virus on a floppy disk is to alert the user to the format of the floppy disk.
Visual basic can format a disk, whether it is a floppy disk or a hard disk, by calling the API function.
Open a new project (Project1), and if you have not changed the default mode, Visual Basic automatically adds a Form1 file, adds a command control to the Form1, and copies the following code into it.
Option Explicit
Private Declare Function shformatdrive Lib "Shell32" _
(ByVal Hend as Long,_
ByVal Drive as Long,_
ByVal FormatID as Long,_
ByVal Options as Long) as long
Private Sub Formatdisk (intdrive as integer,blnquickformat as Boolean)
Dim lngreturn As Long;
if (Blnquickformat) then
lngreturn= shformatdrive (0,intdrive,0&,1&)
Else
lngreturn= shformatdrive (0,intdrive,0&,0&)
End If
End Sub
Private Sub Command1_Click ()
Call Formatdisk (0,true)
End Sub
Run this program.
It is necessary to remind readers that the first variable of the Formatdisk function is important, and his value is 0,1,2 when the format is represented by: A, B, and C.
Note: Readers should never use the hard drive as an experiment when using this program, and I am not responsible for the mistakes and losses that may occur.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.