如何使我的md5病毒扫描速度更快vb.net

时间:2017-09-16 12:19:51

标签: vb.net antivirus

大家好,我目前正在vb.net中制作防病毒软件,当我的防病毒软件正在进行扫描时,程序运行缓慢且滞后可以让它更快吗?这是我认为需要改变的部分。更新:这是我的计时器中的代码,任何人都可以帮助吗?

    ProgressBar1.Maximum = Conversions.ToString(ListBox1.Items.Count)
    total.Text = Conversions.ToString(ListBox1.Items.Count)


    If Not ProgressBar1.Value = ProgressBar1.Maximum Then
        Try

            ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
            Label1.Text = ListBox1.SelectedItem.ToString
        Catch ex As Exception
        End Try



        Try

            Dim scanbox As New TextBox
            Dim read As String = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\Database\VirusList.dat")
            ProgressBar1.Increment(1)
            detected.Text = Conversions.ToString(Quarantine.ListBox2.Items.Count)

            files.Text = Conversions.ToString(ProgressBar1.Value)

            scanbox.Text = read.ToString
            Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
            Dim f As FileStream = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
            f = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
            md5.ComputeHash(f)
            Dim hash As Byte() = md5.Hash
            Dim buff As StringBuilder = New StringBuilder
            Dim hashByte As Byte
            For Each hashByte In hash
                buff.Append(String.Format("{0:X2}", hashByte))
            Next

            If scanbox.Text.Contains(buff.ToString) Then



                Quarantine.ListBox2.Items.Add(ListBox1.SelectedItem)


            End If
        Catch ex As Exception
        End Try
    Else
        Timer1.Stop()

        MsgBox("Finished Scanning")
        Quarantine.Label3.Text = "Pending Quarantine"
        Quarantine.Label2.Text = "Select Item then right click and choose quarantine or delete"
        Quarantine.Label3.ForeColor = Color.DarkRed
        Quarantine.Label2.Location = New Point(142, 518)
        Quarantine.Label2.ForeColor = Color.DarkRed
        Quarantine.QuarantineToolStripMenuItem.Visible = True
        Quarantine.Show()
        RealTime.CheckBox2.Checked = True

        ProgressBar1.Value = 0
        If ListBox1.Items.Count = 0 Then
            MsgBox("No Threats were detected", MsgBoxStyle.Information)
            WriteToLog("No Threats were detected")

        End If
    End If

0 个答案:

没有答案