Convert Console Application Code to Windows Form Application Code?

Herry Markowitz

Well-known member
Joined
Oct 22, 2015
Messages
46
Programming Experience
1-3
Hi beautiful people,
Following Console Application code checks if any antivirus program installed or not in your computer.
VB.NET:
Imports System.Management
Namespace ConsoleApplication1
    Class Program
        Public Shared Function AntivirusInstalled() As Boolean

            Dim wmipathstr As String = "\\" + Environment.MachineName + "\root\SecurityCenter2"
            Try
                Dim searcher As New ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct")
                Dim instances As ManagementObjectCollection = searcher.[Get]()
                Return instances.Count > 0


            Catch e As Exception
                Console.WriteLine(e.Message)
            End Try


            Return False
        End Function


        Public Shared Sub Main(args As String())
            Dim returnCode As Boolean = AntivirusInstalled()
            Console.WriteLine("Antivirus Installed " + returnCode.ToString())
            Console.WriteLine()
            Console.Read()
        End Sub
    End Class
End Namespace


How to convert above code to Windows Form Application Code?

Thanks in advance...
 
Last edited:
The only code there that is specific to Console application is the Console.WriteLine calls. In a Windows Forms project use for example a Label control to display the text.
 
Back
Top