Click here to Skip to main content
15,888,521 members
Articles / Desktop Programming / Win32

Minimal Key Logger Using RAWINPUT

Rate me:
Please Sign up or sign in to vote.
4.71/5 (7 votes)
8 Mar 2013CPOL5 min read 38.7K   2.6K   18  
This is a VB.NET and C# version of "Minimal Key Logger Using RAWINPUT".
Public Class RaiseEventUtility
    Public Shared Sub RaiseEventAndExecuteItInTheTargetThread(ByVal _event As System.MulticastDelegate, ByVal _ParamArray_args() As Object)
        If Not _event Is Nothing Then
            If _event.GetInvocationList().Length > 0 Then
                Dim _sync As System.ComponentModel.ISynchronizeInvoke = Nothing
                For Each _delegate As System.MulticastDelegate In _event.GetInvocationList()
                    If ((_sync Is Nothing) AndAlso (GetType(System.ComponentModel.ISynchronizeInvoke).IsAssignableFrom(_delegate.Target.GetType())) AndAlso (Not _delegate.Target.GetType().IsAbstract)) Then
                        Try
                            _sync = CType(_delegate.Target, System.ComponentModel.ISynchronizeInvoke)
                        Catch ex As Exception
                            Diagnostics.Debug.WriteLine(ex.ToString())
                            _sync = Nothing
                        End Try
                    End If
                    If _sync Is Nothing Then
                        Try
                            _delegate.DynamicInvoke(_ParamArray_args)
                        Catch ex As Exception
                            Diagnostics.Debug.WriteLine(ex.ToString())
                        End Try
                    Else
                        Try
                            _sync.Invoke(_delegate, _ParamArray_args)
                        Catch ex As Exception
                            Diagnostics.Debug.WriteLine(ex.ToString())
                        End Try
                    End If
                Next
            End If
        End If
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions