TeamSpeak

  • VB.NET

Es gibt 20 Antworten in diesem Thema. Der letzte Beitrag () ist von Chris213.

    red-gate.com/products/reflector/

    ich denke, wenn du die Assembly dort per Drag&Drop reinziehst und dir das ganze anguckst, dass du dann schon bemerkst, was das Programm bewirkt ;)
    Ich wollte auch mal ne total überflüssige Signatur:
    ---Leer---
    Ich habe das jetzt alles schön mit dem Reflector hinbekommen, jetzt taucht aber ein Problem auf. Ich muss die Dll hinzufügen "TSRemote" aber ich kann die nicht hinzufügen, da sie keine richtige COM dll ist. Wie kann ich das beheben, gar nicht oder??
    Danke @jvbsl hat geklappt, nur sendet der keine Nachricht an den User, an was könnte das liegen??

    VB.NET-Quellcode

    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_verbinde.Click
    2. Try
    3. AccessTS.AccessTS.Connect(String.Concat(New String() {"teamspeak://", txt_ip.Text, ":", txt_port.Text, "?nickname=", txt_nick.Text, "?loginname=", txt_user.Text, "?password=", txt_pw.Text}))
    4. Catch ex As Exception
    5. MsgBox(ex.Message)
    6. End Try
    7. End Sub
    8. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    9. Dim info As AccessTS.AccessTS.TtsrChannelInfo
    10. For Each info In AccessTS.AccessTS.Channels
    11. AccessTS.AccessTS.SendTextToChannel(info.ChannelID, "Hallo")
    12. AccessTS.AccessTS.SendTextToChannel(info.ChannelParentID, "Hallo")
    13. AccessTS.AccessTS.SendText("Hallo")
    14. Next
    15. End Sub

    und im load event habe ich

    VB.NET-Quellcode

    1. AccessTS.AccessTS.Open()
    stehen

    edit:
    Ich kann wenn ich das

    VB.NET-Quellcode

    1. AccessTS.AccessTS.Connect(String.Concat(New String() {"teamspeak://", txt_ip.Text, ":", txt_port.Text, "?nickname=", txt_nick.Text, "?loginname=", txt_user.Text, "?password=", txt_pw.Text}))

    durch das

    VB.NET-Quellcode

    1. AccessTS.AccessTS.Connect(String.Concat(New String() {"teamspeak://" & txt_ip.Text & ":" & txt_port.Text & "?nickname=" & txt_nick.Text & "?loginname=" & txt_user.Text & "?password=", txt_pw.Text}))

    ersetze kann ich mich mit dem ts server Verbinden, kann aber keine Nachricht senden, ich hoffe ihr könnt mir da helfen.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Chris213“ ()

    Du machst ein Telnet Client mit VB und steuerst dann Teamspeak so>>HIER<<

    Oder du machst die Tsremote.dll aus dem Teamspeak Verzeichnis SDK ind dein Debug Ordner und benuzt den Code da^^

    VB.NET-Quellcode

    1. #Region "tsremote.dll"
    2. <DllImport("TSRemote.dll")> _
    3. Private Shared Sub tsrGetLastError(ByVal pchBuffer As IntPtr, ByVal BufferLength As Integer)
    4. End Sub
    5. <DllImport("TSRemote.dll")> _
    6. Private Shared Function tsrConnect(ByVal URL As String) As Integer
    7. End Function
    8. <DllImport("TSRemote.dll")> _
    9. Private Shared Function tsrDisconnect() As Integer
    10. End Function
    11. <DllImport("TSRemote.dll")> _
    12. Private Shared Function tsrQuit() As Integer
    13. End Function
    14. <DllImport("TSRemote.dll")> _
    15. Private Shared Function tsrSwitchChannelName(ByVal ChannelName As String, ByVal ChannelPassword As String) As Integer
    16. End Function
    17. <DllImport("TSRemote.dll")> _
    18. Private Shared Function tsrSwitchChannelID(ByVal ChannelID As Integer, ByVal ChannelPassword As String) As Integer
    19. End Function
    20. <DllImport("TSRemote.dll")> _
    21. Private Shared Function tsrGetVersion(<[In](), Out()> ByVal tsrVersion As TtsrVersion) As Integer
    22. End Function
    23. <DllImport("TSRemote.dll")> _
    24. Private Shared Function tsrGetServerInfo(ByVal tsrServerInfo As IntPtr) As Integer
    25. End Function
    26. <DllImport("TSRemote.dll")> _
    27. Private Shared Function tsrGetUserInfo(ByVal tsrUserInfo As IntPtr) As Integer
    28. End Function
    29. <DllImport("TSRemote.dll")> _
    30. Private Shared Function tsrGetChannelInfoByID(ByVal ChannelID As Integer, ByVal tsrChannelInfo As IntPtr, ByVal tsrPlayerInfo As IntPtr, ByRef PlayerRecords As Integer) As Integer
    31. End Function
    32. <DllImport("TSRemote.dll")> _
    33. Private Shared Function tsrGetChannelInfoByName(ByVal ChannelName As String, ByVal tsrChannelInfo As IntPtr, ByVal tsrPlayerInfo As IntPtr, ByRef PlayerRecords As Integer) As Integer
    34. End Function
    35. <DllImport("TSRemote.dll")> _
    36. Private Shared Function tsrGetPlayerInfoByID(ByVal PlayerID As Integer, ByVal tsrPlayerInfo As IntPtr) As Integer
    37. End Function
    38. <DllImport("TSRemote.dll")> _
    39. Private Shared Function tsrGetPlayerInfoByName(ByVal PlayerName As String, ByVal tsrPlayerInfo As Integer) As Integer
    40. End Function
    41. <DllImport("TSRemote.dll")> _
    42. Private Shared Function tsrGetChannels(ByVal tsrChannels As IntPtr, ByRef ChannelRecords As Integer) As Integer
    43. End Function
    44. <DllImport("TSRemote.dll")> _
    45. Private Shared Function tsrGetPlayers(ByVal tsrPlayers As IntPtr, ByRef PlayerRecords As Integer) As Integer
    46. End Function
    47. <DllImport("TSRemote.dll")> _
    48. Private Shared Function tsrGetSpeakers(ByVal tsrPlayerIDs As Integer(), ByRef PlayerRecords As Integer) As Integer
    49. End Function
    50. <DllImport("TSRemote.dll")> _
    51. Private Shared Function tsrSetPlayerFlags(ByVal tsrPlayerFlags As Integer) As Integer
    52. End Function
    53. <DllImport("TSRemote.dll")> _
    54. Private Shared Function tsrSetWantVoiceReason(ByVal tsrReason As String) As Integer
    55. End Function
    56. <DllImport("TSRemote.dll")> _
    57. Private Shared Function tsrSetOperator(ByVal PlayerID As Integer, ByVal GrantRevoke As Integer) As Integer
    58. End Function
    59. <DllImport("TSRemote.dll")> _
    60. Private Shared Function tsrSetVoice(ByVal PlayerID As Integer, ByVal GrantRevoke As Integer) As Integer
    61. End Function
    62. <DllImport("TSRemote.dll")> _
    63. Private Shared Function tsrKickPlayerFromServer(ByVal PlayerID As Integer, ByVal Reason As String) As Integer
    64. End Function
    65. <DllImport("TSRemote.dll")> _
    66. Private Shared Function tsrKickPlayerFromChannel(ByVal PlayerID As Integer, ByVal Reason As String) As Integer
    67. End Function
    68. <DllImport("TSRemote.dll")> _
    69. Private Shared Function tsrSendTextMessageToChannel(ByVal ChannelID As Integer, ByVal Message As String) As Integer
    70. End Function
    71. <DllImport("TSRemote.dll")> _
    72. Private Shared Function tsrSendTextMessage(ByVal Message As String) As Integer
    73. End Function
    74. #End Region
    75. #Region "Public Classes for use with TSRemote"
    76. <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    77. Public Class TtsrPlayerInfo
    78. Public PlayerID As Integer = 0
    79. Public ChannelID As Integer = 0
    80. <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=30)> _
    81. Public NickName As String = ""
    82. Public PlayerChannelPrivileges As Integer = 0
    83. Public PlayerPrivileges As Integer = 0
    84. Public PlayerFlags As Integer = 0
    85. Public Logintime As Integer = 0
    86. Public Sub New()
    87. PlayerID = 0
    88. ChannelID = 0
    89. NickName = New String(ControlChars.NullChar, 30)
    90. PlayerChannelPrivileges = 0
    91. PlayerPrivileges = 0
    92. PlayerFlags = 0
    93. Logintime = 0
    94. End Sub
    95. Friend Function ReadHeapValues(ByVal ip As IntPtr) As Integer
    96. If ip.ToInt32() <> 0 Then
    97. Dim offset As Integer = 0
    98. Dim int_size As Integer = Marshal.SizeOf(GetType(Integer))
    99. Dim str_size As Integer = 0
    100. PlayerID = Marshal.ReadInt32(ip)
    101. offset += int_size
    102. ChannelID = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    103. offset += int_size
    104. str_size = NickName.Length
    105. NickName = Marshal.PtrToStringAnsi(New IntPtr(ip.ToInt32() + offset))
    106. offset += str_size
    107. PlayerChannelPrivileges = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    108. offset += int_size
    109. PlayerPrivileges = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    110. offset += int_size
    111. Logintime = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    112. offset += int_size
    113. PlayerFlags = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    114. Return 0
    115. End If
    116. Return -1
    117. End Function
    118. End Class
    119. <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    120. Public Class TtsrChannelInfo
    121. Public ChannelID As Integer
    122. Public ChannelParentID As Integer
    123. Public PlayerCountInChannel As Integer
    124. Public ChannelFlags As Integer
    125. Public Codec As Integer
    126. <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=30)> _
    127. Public Name As String
    128. Public Sub New()
    129. ChannelID = 0
    130. ChannelParentID = 0
    131. PlayerCountInChannel = 0
    132. ChannelFlags = 0
    133. Codec = 0
    134. Name = New String(ControlChars.NullChar, 30)
    135. End Sub
    136. Friend Function ReadHeapValues(ByVal ip As IntPtr) As Integer
    137. If ip.ToInt32() <> 0 Then
    138. Dim offset As Integer = 0
    139. Dim int_size As Integer = Marshal.SizeOf(GetType(Integer))
    140. ChannelID = Marshal.ReadInt32(ip)
    141. offset += int_size
    142. ChannelParentID = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    143. offset += int_size
    144. PlayerCountInChannel = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    145. offset += int_size
    146. ChannelFlags = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    147. offset += int_size
    148. Codec = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    149. offset += int_size
    150. Name = Marshal.PtrToStringAnsi(New IntPtr(ip.ToInt32() + offset))
    151. Return 0
    152. End If
    153. Return -1
    154. End Function
    155. End Class
    156. <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    157. Public Class TtsrVersion
    158. Public Major As Integer = 0
    159. Public Minor As Integer = 0
    160. Public Release As Integer = 0
    161. Public Build As Integer = 0
    162. End Class
    163. <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    164. Public Class TtsrServerInfo
    165. <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=30)> _
    166. Public ServerName As String
    167. <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
    168. Public WelcomeMessage As String
    169. Public ServerVMajor As Integer
    170. Public ServerVMinor As Integer
    171. Public ServerVRelease As Integer
    172. Public ServerVBuild As Integer
    173. <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=30)> _
    174. Public ServerPlatform As String
    175. <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=30)> _
    176. Public ServerIp As String
    177. <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=100)> _
    178. Public ServerHost As String
    179. Public ServerType As Integer
    180. Public ServerMaxUsers As Integer
    181. Public SupportedCodecs As Integer
    182. Public ChannelCount As Integer
    183. Public PlayerCount As Integer
    184. Public Sub New()
    185. ServerName = New String(ControlChars.NullChar, 30)
    186. WelcomeMessage = New String(ControlChars.NullChar, 256)
    187. ServerVMajor = 0
    188. ServerVMinor = 0
    189. ServerVRelease = 0
    190. ServerVBuild = 0
    191. ServerPlatform = New String(ControlChars.NullChar, 30)
    192. ServerIp = New String(ControlChars.NullChar, 30)
    193. ServerHost = New String(ControlChars.NullChar, 100)
    194. ServerType = 0
    195. ServerMaxUsers = 0
    196. SupportedCodecs = 0
    197. ChannelCount = 0
    198. PlayerCount = 0
    199. End Sub
    200. Friend Function ReadHeapValues(ByVal ip As IntPtr) As Integer
    201. If ip.ToInt32() <> 0 Then
    202. Dim offset As Integer = 0
    203. Dim int_size As Integer = Marshal.SizeOf(offset)
    204. Dim str_size As Integer = 0
    205. str_size = ServerName.Length
    206. ServerName = Marshal.PtrToStringAnsi(ip)
    207. offset += str_size
    208. str_size = WelcomeMessage.Length
    209. WelcomeMessage = Marshal.PtrToStringAnsi(New IntPtr(ip.ToInt32() + offset))
    210. offset += str_size
    211. ServerVMajor = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    212. offset += int_size
    213. ServerVMinor = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    214. offset += int_size
    215. ServerVRelease = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    216. offset += int_size
    217. ServerVBuild = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    218. offset += int_size
    219. str_size = ServerPlatform.Length
    220. ServerPlatform = Marshal.PtrToStringAnsi(New IntPtr(ip.ToInt32() + offset))
    221. offset += str_size
    222. str_size = ServerIp.Length
    223. ServerIp = Marshal.PtrToStringAnsi(New IntPtr(ip.ToInt32() + offset))
    224. offset += str_size
    225. str_size = ServerHost.Length
    226. ServerHost = Marshal.PtrToStringAnsi(New IntPtr(ip.ToInt32() + offset))
    227. offset += str_size
    228. ServerType = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    229. offset += int_size
    230. ServerMaxUsers = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    231. offset += int_size
    232. SupportedCodecs = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    233. offset += int_size
    234. ChannelCount = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    235. offset += int_size
    236. PlayerCount = Marshal.ReadInt32(New IntPtr(ip.ToInt32() + offset))
    237. Return 0
    238. End If
    239. Return -1
    240. End Function
    241. End Class
    242. <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
    243. Public Class TtsrUserInfo
    244. Public Player As TtsrPlayerInfo
    245. Public Channel As TtsrChannelInfo
    246. Public ParentChannel As TtsrChannelInfo
    247. Public Sub New()
    248. Player = New TtsrPlayerInfo()
    249. Channel = New TtsrChannelInfo()
    250. ParentChannel = New TtsrChannelInfo()
    251. End Sub
    252. Friend Function ReadHeapValues(ByVal ip As IntPtr) As Integer
    253. If ip.ToInt32() <> 0 Then
    254. Dim offset As Integer = 0
    255. Dim int_size As Integer = Marshal.SizeOf(GetType(Integer))
    256. ' Getting PlayerInfo
    257. Player.ReadHeapValues(ip)
    258. offset = Marshal.SizeOf(GetType(TtsrPlayerInfo))
    259. Channel.ReadHeapValues(New IntPtr(ip.ToInt32() + offset - 2))
    260. offset += Marshal.SizeOf(GetType(TtsrChannelInfo))
    261. ParentChannel.ReadHeapValues(New IntPtr(ip.ToInt32() + offset - 4))
    262. Return 0
    263. End If
    264. Return -1
    265. End Function
    266. End Class
    267. #End Region



    Greetz Haufe
    ähh? wasn das :)

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „haufe“ ()

    Teil 2

    VB.NET-Quellcode

    1. #Region "TSRemote Imports"
    2. Dim tsuserchannelid As String
    3. Dim tsuserid As String
    4. Function GetPlayerInfo(ByVal player_name As String) As Integer
    5. Try
    6. Dim nRetVal As Integer = 0
    7. Dim pi As New TtsrPlayerInfo()
    8. Dim size As Integer = Marshal.SizeOf(GetType(TtsrPlayerInfo))
    9. Dim p_player As System.IntPtr = Marshal.AllocHGlobal(size)
    10. nRetVal = tsrGetPlayerInfoByName(player_name, p_player)
    11. If nRetVal = 0 Then
    12. nRetVal = pi.ReadHeapValues(p_player)
    13. tsuserchannelid = pi.ChannelID
    14. tsuserid = pi.PlayerID
    15. End If
    16. Marshal.DestroyStructure(p_player, GetType(TtsrPlayerInfo))
    17. ' Free the memory that was allocated on the heap, otherwise
    18. ' you will create a memory leak.
    19. Marshal.FreeHGlobal(p_player)
    20. Return pi.PlayerID
    21. Catch ex As Exception
    22. Return Nothing
    23. End Try
    24. End Function
    25. Public Shared Function GetChannelInfo(ByVal channel_name As String) As Integer
    26. Try
    27. Dim nRetVal As Integer = 0
    28. Dim records As Integer = 0
    29. Dim ci As New TtsrChannelInfo()
    30. Dim ci_size As Integer = Marshal.SizeOf(GetType(TtsrChannelInfo))
    31. Dim p_channel As System.Int32 = Marshal.AllocHGlobal(ci_size)
    32. nRetVal = tsrGetChannelInfoByName(channel_name, p_channel, DirectCast(0, Integer), records)
    33. ' now process the items
    34. If nRetVal = 0 Then
    35. nRetVal = ci.ReadHeapValues(p_channel)
    36. Marshal.DestroyStructure(p_channel, GetType(TtsrChannelInfo))
    37. End If
    38. ' Free the memory that was allocated on the heap, otherwise
    39. ' you will create a memory leak.
    40. Marshal.FreeHGlobal(p_channel)
    41. Return ci.ChannelID
    42. Catch ex As Exception
    43. Return Nothing
    44. End Try
    45. End Function
    46. Public Shared ReadOnly Property Channels() As TtsrChannelInfo()
    47. Get
    48. Try
    49. Dim size As Integer = 100
    50. Dim retval As Integer = 0
    51. Dim p_array As IntPtr
    52. Dim p_current As IntPtr
    53. Dim tci As New TtsrChannelInfo()
    54. p_array = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(TtsrChannelInfo)))
    55. retval = tsrGetChannels(p_array, size)
    56. Dim channels1 As TtsrChannelInfo() = New TtsrChannelInfo(size - 1) {}
    57. p_current = p_array
    58. For i As Integer = 0 To size - 1
    59. channels1(i) = New TtsrChannelInfo()
    60. ' this is where you'll create a new object and copy the data over instead of
    61. ' using this stupid array.
    62. Marshal.PtrToStructure(p_current, channels1(i))
    63. Marshal.DestroyStructure(p_current, GetType(TtsrChannelInfo))
    64. p_current = DirectCast((CInt(p_current) + Marshal.SizeOf(GetType(TtsrChannelInfo)) - 2), Integer)
    65. Next
    66. Marshal.FreeHGlobal(p_array)
    67. System.GC.Collect()
    68. Return channels1
    69. Catch ex As Exception
    70. Return Nothing
    71. End Try
    72. End Get
    73. End Property
    74. Public Shared ReadOnly Property Players() As TtsrPlayerInfo()
    75. Get
    76. Try
    77. Const MAX_PLAYERS As Integer = 200
    78. Dim records As Integer = MAX_PLAYERS
    79. Dim nRetVal As Integer = 0
    80. Dim arr_players As TtsrPlayerInfo()
    81. Dim size As Integer = Marshal.SizeOf(GetType(TtsrPlayerInfo)) * MAX_PLAYERS
    82. Dim p_player As System.IntPtr = Marshal.AllocHGlobal(size)
    83. Dim p_current As System.IntPtr
    84. nRetVal = tsrGetPlayers(p_player, records)
    85. If nRetVal = 0 Then
    86. ' keep track of our player pointer
    87. p_current = p_player
    88. arr_players = New TtsrPlayerInfo(records - 1) {}
    89. For i As Integer = 0 To records - 1
    90. arr_players(i) = New TtsrPlayerInfo()
    91. nRetVal = arr_players(i).ReadHeapValues(p_current)
    92. Marshal.DestroyStructure(p_current, GetType(TtsrPlayerInfo))
    93. p_current = DirectCast((CInt(p_current) + Marshal.SizeOf(GetType(TtsrPlayerInfo)) - 6), Integer)
    94. Next
    95. Else
    96. arr_players = New TtsrPlayerInfo(-1) {}
    97. End If
    98. ' Free the memory that was allocated on the heap, otherwise
    99. ' you will create a memory leak.
    100. Marshal.FreeHGlobal(p_player)
    101. Return arr_players
    102. Catch
    103. Return Nothing
    104. End Try
    105. End Get
    106. End Property
    107. Public Shared ReadOnly Property ServerInfo() As TtsrServerInfo
    108. Get
    109. Try
    110. Dim nRetVal As Integer = 0
    111. Dim size As Integer = Marshal.SizeOf(GetType(TtsrServerInfo))
    112. Dim si As New TtsrServerInfo()
    113. Dim p_current As System.IntPtr = Marshal.AllocHGlobal(size)
    114. nRetVal = tsrGetServerInfo(p_current)
    115. If nRetVal = 0 Then
    116. ' this is where you'll create a new object and copy the data over instead of
    117. ' using this stupid array.
    118. si.ReadHeapValues(p_current)
    119. Marshal.DestroyStructure(p_current, GetType(TtsrServerInfo))
    120. End If
    121. ' Free the memory that was allocated on the heap, otherwise
    122. ' you will create a memory leak.
    123. Marshal.FreeHGlobal(p_current)
    124. Return si
    125. Catch ex As Exception
    126. Return Nothing
    127. End Try
    128. End Get
    129. End Property
    130. #End Region
    ähh? wasn das :)
    man man man XD
    ist doch einfach

    VB.NET-Quellcode

    1. <DllImport("TSRemote.dll")> _
    2. Private Shared Function tsrSendTextMessageToChannel(ByVal ChannelID As Integer, ByVal Message As String) As Integer
    3. End Function

    und den code in ein button

    VB.NET-Quellcode

    1. tsrSendTextMessageToChannel(1,"hallo")


    Nur noch zur Information:

    Die Funktionen der TSREMOTE.dll können nur mit installierten und auch gestarteten Teamspeak 2 genuzt werden!!!!
    ähh? wasn das :)

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „haufe“ ()