winlirc

fablio

Grünschnabel
Ich möchte meine Anwendung mit einer Fernbedienung steuern.
Ich habe leider nur einen Code für VB6 gefunden. Wie mache ich das mit .NET mit c#?


Hier der VB6 code
Code:
'Include the Microsoft Winsock Control 5.0 Componente an Create an Object
'like Winsock1. Open connection to the WinLircServer like in the Form_Load()
'Procedure. Since now, the open was O.K, you can receive messages with the
'Winsock1_DataArrival() Procedure. Everytime WinLirc recognices a remote key
'it will be send to all connected (max. 6) programms. In this case the
'Winsock1_DataArrival() will be called if data is received from WinLirc.

Private Sub Form_Load()
   
    Dim strLocalIP As String
   
    strLocalIP = Winsock1.LocalIP
    Winsock1.Protocol = sckTCPProtocol
    Winsock1.RemoteHost = strLocalIP
    Winsock1.RemotePort = 8765
    Winsock1.Connect

End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    Dim strData As String
    Dim strRemoteHex, strRemoteName, strRemoteKey As String
    Dim intRemoteIdx, intSeperatorOne, intSeperatorTwo As Integer
    
    Winsock1.GetData strData, vbString
    Text1.Text = strData    'Messagestring from WinLirc
    
    strRemoteHex = Left(strData, 16)
    intRemoteIdx = Val(Mid$(strData, 18, 2))
    
    intSeperatorOne = InStr(21, strData, " ", vbBinaryCompare)'
    strRemoteKey = Mid$(strData, 21, intSeperatorOne - 21) 'Code of the Key from Remote Control
    
    intSeperatorTwo = InStr(intSeperatorOne, strData, Chr(10), vbBinaryCompare)
    strRemoteName = Mid$(strData, intSeperatorOne + 1, (intSeperatorTwo - intSeperatorOne) - 1) 'Name of the Key - defined in WinLircServer
    
    Text2.Text = "KEY:" & strRemoteKey & " Control:" & strRemoteName
    
End Sub
 
Zurück