Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)

Iniciado por Eleкtro, 18 Diciembre 2012, 22:23 PM

0 Miembros y 1 Visitante están viendo este tema.

Eleкtro

GeoLocalizar una IP:

Código (vbnet) [Seleccionar]
#Region " GeoLocation "

' [ GeoLocation ]
'
' // By Elektro H@cker
'
' Examples :
'
' Dim GeoInfo As GeoLocation.GeoInfo = GeoLocation.Locate("84.126.113.11")
' Dim GeoInfo As GeoLocation.GeoInfo = GeoLocation.Locate("84.126.113.11.dyn.user.ono.com")
' MsgBox(GeoInfo.Country) ' result: Spain
' MsgBox(GeoInfo.City)    ' Result: Valencia

Public Class GeoLocation

    Public Class GeoInfo
        Public Property Latitude() As String
        Public Property Lognitude() As String
        Public Property City() As String
        Public Property State() As String
        Public Property Country() As String
        Public Property Host() As String
        Public Property Ip() As String
        Public Property Code() As String
    End Class

    Public Shared Function Locate(ByVal IP As String) As GeoInfo

        Try

            Dim request = TryCast(Net.WebRequest.Create(New Uri("http://www.geoiptool.com/data.php/en/?IP=" & IP)), Net.HttpWebRequest)

            If request IsNot Nothing Then

                request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727)"

                Dim _geoloc As New GeoInfo

                Using webResponse = TryCast(request.GetResponse(), Net.HttpWebResponse)
                    If webResponse IsNot Nothing Then

                        Using reader = New IO.StreamReader(webResponse.GetResponseStream())

                            Dim doc = New Xml.XmlDocument()

                            doc.Load(reader)

                            Dim nodes = doc.GetElementsByTagName("marker")

                            Dim marker = TryCast(nodes(0), Xml.XmlElement)

                            _geoloc.City = marker.GetAttribute("city")
                            _geoloc.Country = marker.GetAttribute("country")
                            _geoloc.Code = marker.GetAttribute("code")
                            _geoloc.Host = marker.GetAttribute("host")
                            _geoloc.Ip = marker.GetAttribute("ip")
                            _geoloc.Latitude = marker.GetAttribute("lat")
                            _geoloc.Lognitude = marker.GetAttribute("lng")

                            Return _geoloc

                        End Using

                    End If
                End Using
            End If

            Return New GeoInfo()

        Catch ex As Exception
            Throw New Exception(ex.Message)
        End Try

    End Function

End Class

#End Region








Novlucker

Implementación en C#
Código (csharp) [Seleccionar]
    public class GeoLocation
    {
        [XmlRoot("markers")]
        public class markers
        {
            [XmlElement("marker")]
            public List<GeoIfo> marker { get; set; }
        }

        public class GeoIfo
        {
            [XmlAttribute("lat")]
            public string Latitude { get; set; }
            [XmlAttribute("lng")]
            public string Longitude { get; set; }
            [XmlAttribute("city")]
            public string City { get; set; }
            [XmlAttribute("country")]
            public string Country { get; set; }
            [XmlAttribute("host")]
            public string Host { get; set; }
            [XmlAttribute("ip")]
            public string Ip { get; set; }
            [XmlAttribute("code")]
            public string Code { get; set; }
        }

        public static GeoIfo Locate(string IP)
        {
            WebClient client = new WebClient();
            string xml = client.DownloadString(string.Format("{0}{1}", "http://www.geoiptool.com/data.php/en/?IP=", IP));
            XmlSerializer serializer = new XmlSerializer(typeof(markers));
            markers geoInfo;

            using (StringReader reader = new StringReader(xml))
            {
                geoInfo = (markers)serializer.Deserialize(reader);
            }

            return geoInfo.marker.First();
        }
    }
Contribuye con la limpieza del foro, reporta los "casos perdidos" a un MOD XD

"Hay dos cosas infinitas: el Universo y la estupidez  humana. Y de la primera no estoy muy seguro."
Albert Einstein

z3nth10n

#192
Ala, ya si se puede decir que Nov a "ayudado" :P




Googleando un poquito he encontrado esto:

Código (vbnet) [Seleccionar]
Public Class Form1
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       WebBrowser1.Navigate("http://google.com")
   End Sub
   Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
       AddHandler WebBrowser1.Document.Click, AddressOf getClickedElement
   End Sub
   Private Sub getClickedElement(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
       With WebBrowser1.Document.GetElementFromPoint(e.ClientMousePosition)
           Dim selectedHtmlElement_ID As String = .GetAttribute("id").ToLower
           Dim selectedHtmlElement_NAME As String = .GetAttribute("name").ToLower
           MsgBox("ID: " & selectedHtmlElement_ID & vbNewLine & " --- Name: " & selectedHtmlElement_NAME)
       End With
   End Sub
End Class


Básicamente podemos sacar el Name y la Id del elemento clicado a través de un MsgBox.

Un saludo. :)
Que os parece? :P

Interesados hablad por Discord.

Novlucker

Cita de: Ikillnukes en 20 Junio 2013, 17:39 PM
Ala, ya si se puede decir que Nov a "ayudado" :P

Es que insisto, muchos códigos si me parecen útiles, pero otros se me hacen demasiado evidentes como para tener que buscarlos en algún sitio, demoro menos codeandolo, ej;
"Get_Method", y "Comprueba si un numero es divisible por otro": https://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1857426#msg1857426
"Download_URL_SourceCode": https://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1856078#msg1856078
"Elimina un Item de un Array": https://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1856079#msg1856079

Saludos
Contribuye con la limpieza del foro, reporta los "casos perdidos" a un MOD XD

"Hay dos cosas infinitas: el Universo y la estupidez  humana. Y de la primera no estoy muy seguro."
Albert Einstein

Eleкtro

#194
Un Bot para IRC.

No soy experto en IRC, lo hice basándome en wl webchat de freenode, pero imagino que funcionará en todos los canales de IRC.

...Extender y/o modificar el código como querais, esto solo e sun ejemplo, dejar volar vuestra imaginación:


Un ejemplo de uso:

Código (vbnet) [Seleccionar]
Public Class Form1

   Dim IRC_Thread_Var As Threading.Thread = New Threading.Thread(AddressOf IRC_Thread)

   Private Sub Form1_shown(sender As Object, e As EventArgs) Handles MyBase.Shown
       IRC_Thread_Var = New Threading.Thread(AddressOf IRC_Thread)
       IRC_Thread_Var.Start()
   End Sub

   Sub IRC_Thread()
       IRC_Bot.Connect("irc.freenode.org", "#ircehn", "ElektroBot")
   End Sub

End Class


...La class del Bot:
Código (vbnet) [Seleccionar]
Public Class IRC_Bot

   ' Channel Moderators
   Public Shared Gods As String() = "Elektro Elektro-H Elektro-H_ Drvy kili4n Ikillnukes Caster_ OmarHack OmarHack_ Carloswaldo _0xDani".Split(ChrW(32)).ToArray

   ' Commands
   Private Shared Line As String = Nothing
   Private Shared Name As String = Nothing
   Private Shared IP As String = Nothing
   Private Shared Command As String = Nothing
   Private Shared Argument As String = Nothing

   ' Bot Status
   Public Shared Activated As Boolean = True
   Private Shared Elapsed_Time As New Stopwatch
   Private Shared Total_Messages As Int64 = 0

   ' Connection
   Private Shared Ident_Listener As Net.Sockets.TcpListener = Nothing
   Private Shared Ident_Client As Net.Sockets.TcpClient = Nothing
   Private Shared Ident_NetworkStream As Net.Sockets.NetworkStream = Nothing
   Private Shared Ident_Reader As IO.StreamReader = Nothing
   Private Shared Ident_Writer As IO.StreamWriter = Nothing
   Private Shared Ident_ResponseString As String = Nothing
   Private Shared TCP_client As Net.Sockets.TcpClient = Nothing ' Main connection to the IRC network.
   Private Shared Network_Stream As Net.Sockets.NetworkStream = Nothing ' Break TCP connection down to a network stream.
   Private Shared IRC_Reader As IO.StreamReader = Nothing ' Stream to read messages from the Server.
   Private Shared IRC_Writer As IO.StreamWriter = Nothing ' Stream to write messages to the server.

   ' To attach Console (If needed)
   ' Private Declare Function AllocConsole Lib "kernel32.dll" () As Boolean

   Public Shared Sub Connect(ByVal Server As String, _
                      ByVal Channel As String, _
                      ByVal NickName As String, _
                      Optional ByVal Port As Int32 = 6667, _
                      Optional ByVal RealName As String = "ElektroBot", _
                      Optional ByVal UserName As String = "ElektroHacker")

       ' AllocConsole() '  Attach Console (If needed)

       ' Change CMD Window Size
       Console.SetWindowSize(200, 60)

       Try

           ' Create Connection
           Write("Creating Connection...", ConsoleColor.Yellow)
           TCP_client = New Net.Sockets.TcpClient(Server, Port)
           Network_Stream = TCP_client.GetStream
           IRC_Reader = New IO.StreamReader(Network_Stream)
           IRC_Writer = New IO.StreamWriter(Network_Stream)
           If Not IRC_Writer.AutoFlush Then IRC_Writer.AutoFlush = True

           ' Set name
           Write("Setting up name...", ConsoleColor.Yellow)
           IRC_Writer.WriteLine(String.Format("USER {0} {1} * :{2}", UserName, 0, RealName))

           ' Set Nickname
           Write("Setting Nickname...", ConsoleColor.Yellow)
           IRC_Writer.WriteLine(String.Format("NICK {0}", NickName))

           ' Join Room
           Write("Joining Room...", ConsoleColor.Yellow)
           IRC_Writer.WriteLine(String.Format("JOIN {0}", Channel))

           ' Check Ident connection
           Write("Checking Ident connection...", ConsoleColor.Yellow)
           Ident_Listener = New Net.Sockets.TcpListener(Net.IPAddress.Any, 113)
           Ident_Listener.Start()
           Ident_Client = Ident_Listener.AcceptTcpClient
           Ident_Listener.Stop()
           Ident_NetworkStream = Ident_Client.GetStream
           Ident_Reader = New IO.StreamReader(Ident_NetworkStream)
           Ident_ResponseString = Ident_Reader.ReadLine
           Write("Ident got: " & Ident_ResponseString, ConsoleColor.Cyan)
           Ident_Writer = New IO.StreamWriter(Ident_NetworkStream)
           If Not Ident_Writer.AutoFlush Then Ident_Writer.AutoFlush = True
           Ident_Writer.WriteLine(String.Format("{0} : USERID : WINDOWS 7 : {1}", Ident_ResponseString, UserName))

           ' Read messages
           Write("Reading messages...", ConsoleColor.Yellow)
           Elapsed_Time.Start()

           While True

               ' Sum the total received messages
               Total_Messages += 1

               ' Get the IRC line to read
               Line = IRC_Reader.ReadLine

               ' Print the IRC line
               Write(Line, ConsoleColor.Gray)

               ' Get User Name
               Try : Name = Line.Split("!").First.Substring(1, Line.Split("!").First.Length - 1)
               Catch : Name = Nothing
               End Try

               ' Get User IP
               Try : IP = Line.Split(" ").First.Split("/").Last.Replace("ip.", "")
               Catch : IP = Nothing
               End Try

               ' Get User Command
               Try : Command = Line.Split(" ")(3).Substring(1, Line.Split(" ")(3).Length - 1).ToLower
               Catch : Command = Nothing
               End Try

               ' Get the command argument
               Try : Argument = Line.Split(" ")(4)
               Catch : Argument = Nothing
               End Try

                    ' IRC Ping-Pong
                    if line.tolower.startswith("ping") then
                        Write("Answering Ping with Pong...", ConsoleColor.Yellow)
                        Write("PONG " & Line, ConsoleColor.Cyan)
                        IRC_Writer.WriteLine("PONG " & Line)
                    end if

               ' Parse commands
               Select Case Command

                       ' Help
                   Case "!?", "!ayuda"

                       If Line.ToLower.Contains(Channel.ToLower) Then
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}      ", Name, "[+] Comandos públicos:"))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!? | !ayuda      ", "Muestra esta ayuda."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!reglas          ", "Muestra las reglas de la sala."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!reglasehn       ", "Muestra las reglas de ElHacker.Net."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!status          ", "Muestra el estado del Bot."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!Whois (IP)      ", "Muestra información geográfica de una IP."))

                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}      ", Name, "[+] Comandos privados:"))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!op              ", "Te otorga el estado de OP."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!op(+|-) (NOMBRE)", "Otorga o elimina el estado de OP a un usuario."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!bot (ON|OFF)    ", "Activa o Desactiva el Bot."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} | {2}", Name, "!q | !quit       ", "Desconecta al Bot."))
                       End If

                       ' Room Rules
                   Case "!reglas"

                       If Line.ToLower.Contains(Channel.ToLower) Then
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "[+] Reglas de " & Channel))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "1. Respetar a los usuarios y no ofender de ninguna manera."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "2. No preguntar como puedes hackear a personas ajenas."))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "3. No compartir material pornográfico o difundir la pederástia o cosas parecidas."))
                       End If

                       ' EHN Rules
                   Case "!reglasehn"

                       If Line.ToLower.Contains(Channel.ToLower) Then
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}", Name, "[+] Reglas de ElHacker.Net: http://foro.elhacker.net/reglas"))
                       End If

                       ' Geo-Locate IP
                   Case "!whois"

                       'If Line.ToLower.Contains(Channel.ToLower) Then _
                       'AndAlso Activated Then

                       'Dim GeoInfo As GeoLocation.GeoInfo = GeoLocation.Locate(Argument)
                       'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "[+] Información geográfica de ", Argument))
                       'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "País..:", GeoInfo.Country))
                       'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Ciudad:", GeoInfo.City))
                       'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Código:", GeoInfo.Code))
                       'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Host..:", GeoInfo.Host))
                       'IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Ip....:", GeoInfo.Ip))
                       'GeoInfo = Nothing

                       ' End If

                       ' Give own OP+
                   Case "!op"

                       If Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) _
                       AndAlso Activated Then

                           IRC_Writer.WriteLine(String.Format("MODE {0} +o {1}", Channel, Name))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "se ha convertido en OP."))

                       ElseIf Not Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) _
                       AndAlso Activated Then

                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios para ser OP."))

                       End If

                       ' Give Op+ to a user
                   Case "!op+"

                       If Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) _
                       AndAlso Activated Then

                           IRC_Writer.WriteLine("MODE {0} +o {1}", Channel, Argument)
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2} {3}", Channel, Name, "concedió OP a", Argument))

                       ElseIf Not Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) _
                       AndAlso Activated Then

                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios para conceder OP."))

                       End If

                       ' Give Op- to a user
                   Case "!op-"

                       If Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) _
                       AndAlso Activated Then

                           IRC_Writer.WriteLine("MODE {0} -o {1}", Channel, Argument)
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2} {3}", Channel, Name, "denegó OP a", Argument))

                       ElseIf Not Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) _
                       AndAlso Activated Then

                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios para denegar OP."))

                       End If

                       ' Bot ON/OFF
                   Case "!bot"

                       If Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) Then

                           Select Case Argument.ToLower
                               Case "on"
                                   Activated = True
                                   Write("Bot status changed to: Enabled", ConsoleColor.Cyan)
                               Case "off"
                                   Activated = False
                                   Write("Bot status changed to: Disabled", ConsoleColor.Cyan)
                           End Select

                       ElseIf Not Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) Then

                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} :{1} {2}", Channel, Name, "no tienes privilegios de OP."))

                       End If

                       ' Bot Status
                   Case "!status"

                       If Line.ToLower.Contains(Channel.ToLower) Then
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1}    ", Name, "[+] Status del Bot"))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Soy propiedad de......:", "Elektro-H"))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Versión de mi sistema.:", "0.2"))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Tiempo total online...:", Elapsed_Time.Elapsed.Hours & " H, " & Elapsed_Time.Elapsed.Minutes & " M, " & Elapsed_Time.Elapsed.Seconds & " S"))
                           IRC_Writer.WriteLine(String.Format("PRIVMSG {0} : {1} {2}", Name, "Mensajes procesados...:", Total_Messages))
                       End If

                       ' Quit
                   Case "!q", "!quit"

                       If Gods.Contains(Name) _
                       AndAlso Line.ToLower.Contains(Channel.ToLower) _
                       AndAlso Activated Then

                           IRC_Writer.WriteLine("QUIT")
                           Write("Exiting...", ConsoleColor.Yellow)
                           Exit Sub

                       End If

               End Select

           End While

       Catch ex As Exception
           Write("Error: " & ex.Message, ConsoleColor.Red)
           IRC_Writer.WriteLine("QUIT")

       Finally
           IRC_Reader.Dispose()
           IRC_Writer.Dispose()
           Network_Stream.Dispose()

       End Try

   End Sub

   Private Shared Sub Write(ByVal Text As String, _
                                Optional ByVal ForeColor As System.ConsoleColor = ConsoleColor.White, _
                                Optional ByVal BackColor As System.ConsoleColor = ConsoleColor.Black)

       Dim Current_ForegroundColor As ConsoleColor = Console.ForegroundColor
       Dim Current_BackgroundColor As ConsoleColor = Console.BackgroundColor

       Console.ForegroundColor = ForeColor
       Console.BackgroundColor = BackColor
       Console.WriteLine(Text & vbNewLine)

       Console.ForegroundColor = Current_ForegroundColor
       Console.BackgroundColor = Current_BackgroundColor

   End Sub

End Class








z3nth10n


Interesados hablad por Discord.

Eleкtro

#196
Cita de: Ikillnukes en 20 Junio 2013, 20:45 PMy las captchas? :rolleyes:
El captcha te lo pide la web de freenode, no el protocolo IRC.
no es necesario, pruébalo xD...








Eleкtro









z3nth10n

Cita de: EleKtro H@cker en 20 Junio 2013, 21:38 PM
El captcha te lo pide la web de freenode, no el protocolo IRC.
no es necesario, pruébalo xD...

Okey, gracias :)

Interesados hablad por Discord.

Eleкtro

#199
Obtener en WinAmp el título o la ruta del archivo de la canción actual.

PD: Son códigos de VB6 que convertí a .NET (no todo...) con algo de ayuda.

Código (vbnet) [Seleccionar]
#Region " WinAmp Info"

' [ WinAmp Info ]
'
' // By Elektro H@cker
'
' Examples:
' MsgBox(WinAmp.Get_Title)    ' Result: Artist - Title
' MsgBox(WinAmp.Get_FileName) ' Result: C:\Title.ext

Public Class WinAmp

   Private Const WinampClassName As String = "Winamp v1.x"

   Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
   Private Declare Auto Function GetWindowText Lib "user32" (ByVal hwnd As IntPtr, ByVal lpString As String, ByVal cch As Integer) As Integer
   Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, ByRef lpdwProcessId As Long) As Long
   Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
   Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
   Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByRef lpBuffer As Byte, ByVal nSize As Long, ByRef lpNumberOfBytesRead As Long) As Long
   Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

   Public Shared Function Get_Title() As String

       Dim hwnd As IntPtr = FindWindow(WinampClassName, vbNullString)

       Dim lpText As String = String.Empty
       Dim strTitle As String = String.Empty

       Dim intLength As Integer = 0
       Dim intName As Integer = 0
       Dim intLeft As Integer = 0
       Dim intRight As Integer = 0
       Dim intDot As Integer = 0

       If hwnd.Equals(IntPtr.Zero) Then Return "WinAmp is not running"

       lpText = New String(Chr(0), 100)
       intLength = GetWindowText(hwnd, lpText, lpText.Length)

       If (intLength <= 0) _
       OrElse (intLength > lpText.Length) _
       Then Return "Unknown"

       strTitle = lpText.Substring(0, intLength)
       intName = strTitle.IndexOf(" - Winamp")
       intLeft = strTitle.IndexOf("[")
       intRight = strTitle.IndexOf("]")

       If (intName >= 0) _
       AndAlso (intLeft >= 0) _
       AndAlso (intName < intLeft) _
       AndAlso (intRight >= 0) _
       AndAlso (intLeft + 1 < intRight) _
       Then Return strTitle.Substring(intLeft + 1, intRight - intLeft - 1)

       If (strTitle.EndsWith(" - Winamp")) _
       AndAlso (strTitle.Length > " - Winamp".Length) _
       Then strTitle = strTitle.Substring(0, strTitle.Length - " - Winamp".Length)

       intDot = strTitle.IndexOf(".")

       If (intDot > 0) _
       AndAlso (IsNumeric(strTitle.Substring(0, intDot))) _
       Then strTitle = strTitle.Remove(0, intDot + 1)

       Return strTitle.Trim

   End Function

   Public Shared Function Get_FileName() As String

       Dim lp As Long, lpWinamp As Long, iIndex As Long, PID As Long, bRet As Long, dwRead As Long
       Dim Buffer(260) As Byte

       Dim hWndWinamp As IntPtr = FindWindow(WinampClassName, vbNullString)
       If hWndWinamp = 0 Then Return Nothing

       iIndex = SendMessage(hWndWinamp, &H400, 0, 125)

       lp = SendMessage(hWndWinamp, &H400, iIndex, 211)
       If lp = 0 Then Return Nothing

       Call GetWindowThreadProcessId(hWndWinamp, PID)

       lpWinamp = OpenProcess(&H10, 0, PID)
       If lpWinamp = 0 Then Return Nothing

       bRet = ReadProcessMemory(lpWinamp, lp, Buffer(0), 260, dwRead)

       Call CloseHandle(lpWinamp)

       Return System.Text.UnicodeEncoding.Default.GetString(Buffer)

   End Function

End Class

#End Region