Hack Forums
[.NET] Some maybe usefull snippets - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Some maybe usefull snippets (/showthread.php?tid=4571175)



Some maybe usefull snippets - imi-tat0r - Dec 5, 2014

Found these while sorting my Harddrive:

GetAVInformation() - Gets the installed AVs name.
Code
Public Function GetAVInformation(ByVal strSystem As String) As String
        Dim strComputer As String = String.Empty
        Dim wmiNS As String = String.Empty
        Dim wmiQuery As String = String.Empty
        Dim objWMIService As Object
        Dim ColItems As Object
        Dim objItem As Object
        Dim str58 As New System.Text.StringBuilder
        Try
            If strSystem = System.Environment.MachineName Then
                strComputer = "."
            Else
                strComputer = strSystem
            End If
            wmiNS = "\root\SecurityCenter2" 'Windows XP SecurityCenter
            wmiQuery = "Select * from AntiVirusProduct"
            objWMIService = Microsoft.VisualBasic.GetObject("winmgmts:\\" & strComputer & wmiNS)
            ColItems = objWMIService.ExecQuery(wmiQuery)
            For Each objItem In ColItems
                Try
                    str58.AppendLine(objItem.displayname.ToString)
                Catch ex As System.Exception
                    str58.AppendLine("??" & Microsoft.VisualBasic.vbTab & Microsoft.VisualBasic.vbTab & Microsoft.VisualBasic.vbTab & "??")
                End Try
            Next
        Catch ex As System.Exception

        End Try
        'Log("AV is " + str58.ToString)
        Return str58.ToString
    End Function

GetSoftware() - Gets all installed Programs.
Code
Public Function GetSoftware() As String
        
Dim DestKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
        GetSoftware = ""

Dim value as String = ""
        For Each App As String In Microsoft.Win32.Registry.LocalMachine.OpenSubKey(DestKey).GetSubKeyNames

value = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(DestKey & App & "\").GetValue("DisplayName")

    if value <> "" then
            GetSoftware += "NewBlock-.-.-.-" & value
    end if
        Next
        Return GetSoftware

    End Function



* - Rhez - Dec 5, 2014

Can you put how to use this one ? :) Thanks in advance


* - imi-tat0r - Dec 5, 2014

Put them in your code and call the functions

Code
Dim AVInfo as String = GetAVInformation()
Dim Software as String = GetSoftware()

BUT GetSoftware gives a String in the following format: "SoftwarenameNewBlock-.-.-.-SoftwarenameNewBlock-.-.-.-"
So you have to split the string into a Stringarray.
Delimiter = NewBlock-.-.-.-

It's bad code I know but as I said I found them on my Harddrive :)


* - Rhez - Dec 6, 2014

There's is no bad code sir .
BTW Thanks for this


* - Odus - Dec 6, 2014

(Dec 5, 2014 09:45 PM)imi-tat0r Wrote:  BUT GetSoftware gives a String in the following format: "SoftwarenameNewBlock-.-.-.-SoftwarenameNewBlock-.-.-.-"
So you have to split the string into a Stringarray.
Delimiter = NewBlock-.-.-.-

You're appending the string with each new block... Just feed them into an array to begin with.


* - imi-tat0r - Dec 6, 2014

(Dec 6, 2014 06:00 AM)Odus Wrote:  You're appending the string with each new block... Just feed them into an array to begin with.

As I said this is bad code and I just found them on my Harddrive. I did not code this