vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
sevAniGif - als kostenlose Vollversion auf unserer vb@rchiv CD Vol.5  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: Poste mal, was Du bis jetzt hast. (oT) 
Autor: Xelion
Datum: 01.04.02 19:55

also das ist die form auf der angezeigt werden soll, wie der name, der status, der ping des computers mit der ip-nummer, die in IPNummer drin steht. was noch nicht funktioniert ist das der name angezeigt wird.
hier der scoure code:

Private Sub Aktualisieren_Click()
Dim strComputername As String
Dim ECHO As ICMP_ECHO_REPLY
Dim pos As Integer
'Die Ping-Funktion aufrufen:
Call Ping(Trim$(Form1.IPNummer), ECHO)

'Ergebnisse anzeigen
Status2.Caption = GetStatusCode(ECHO.Status)
Zeit2.Caption = ECHO.RoundTripTime & " ms"
Datasize2.Caption = ECHO.Datasize & " bytes"
If ECHO.Status = 0 Then
LEDStatus.Picture = LoadPicture("LEDgrün2.bmp")
Else
LEDStatus.Picture = LoadPicture("LEDrot2.bmp")
End If

Form2.Caption = "Infos über PC mit der IP: " & Form1.IPNummer
IP2.Caption = Form1.IPNummer
strComputername = Form1.IPNummer
End Sub
Private Sub Form_Load()
Dim ECHO As ICMP_ECHO_REPLY
Dim pos As Integer
'Die Ping-Funktion aufrufen:
Call Ping(Trim$(Form1.IPNummer), ECHO)

'Ergebnisse anzeigen
Status2.Caption = GetStatusCode(ECHO.Status)
Zeit2.Caption = ECHO.RoundTripTime & " ms"
Datasize2.Caption = ECHO.Datasize & " bytes"
If ECHO.Status = 0 Then
LEDStatus.Picture = LoadPicture("LEDgrün2.bmp")
Else
LEDStatus.Picture = LoadPicture("LEDrot2.bmp")
End If

Form2.Caption = "Infos über PC mit der IP: " & Form1.IPNummer
IP2.Caption = Form1.IPNummer
End Sub



und dann habe ich noch ein modulmit dem ich den ping und den status bekomme:

Option Explicit

Private Declare Function IcmpCreateFile Lib "icmp.dll" () _
As Long

Private Declare Function IcmpCloseHandle Lib "icmp.dll" (ByVal _
IcmpHandle As Long) As Long

Private Declare Function IcmpSendEcho Lib "icmp.dll" (ByVal _
IcmpHandle As Long, ByVal DestinationAddress As Long, _
ByVal RequestData As String, ByVal RequestSize As _
Integer, ByVal RequestOptions As Long, ReplyBuffer As _
ICMP_ECHO_REPLY, ByVal ReplySize As Long, ByVal _
TimeOut As Long) As Long

Private Declare Function WSAGetLastError Lib "wsock32.dll" () _
As Long

Private Declare Function WSAStartup Lib "wsock32.dll" (ByVal _
wVersionRequired As Long, lpWSADATA As WSAData) As Long

Private Declare Function WSACleanup Lib "wsock32.dll" ( _
) As Long

Private Declare Function GetHostName Lib "wsock32.dll" Alias _
"gethostname" (ByVal szHost As String, ByVal dwHostLen _
As Long) As Long

Private Declare Function gethostbyname Lib "wsock32.dll" ( _
ByVal szHost As String) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As _
Long, ByVal cbCopy As Long)

Private Declare Function htonl Lib "wsock32.dll" (ByVal hostlong _
As Long) As Long

Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort _
As Long) As Integer

Private Declare Function inet_addr Lib "wsock32.dll" (ByVal cp _
As String) As Long

Private Declare Function inet_ntoa Lib "wsock32.dll" (ByVal inn _
As Long) As Long

Private Declare Function ntohl Lib "wsock32.dll" (ByVal netlong _
As Long) As Long

Private Declare Function ntohs Lib "wsock32.dll" (ByVal netshort _
As Long) As Integer

Private Type ICMP_OPTIONS
Ttl As Byte
Tos As Byte
Flags As Byte
OptionsSize As Byte
OptionsData As Long
End Type

Public Type ICMP_ECHO_REPLY
Address As Long
Status As Long
RoundTripTime As Long
Datasize As Integer
Reserved As Integer
DataPointer As Long
Options As ICMP_OPTIONS
Data As String * 250
End Type

Private Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type

Const MAX_WSADescription = 256
Const MAX_WSASYSStatus = 128
Const MAXGETHOSTSTRUCT = 1024

Private Type WSAData
wVersion As Integer
wHighVersion As Integer
szDescription(0 To MAX_WSADescription) As Byte
szSystemStatus(0 To MAX_WSASYSStatus) As Byte
wMaxSockets As Integer
wMaxUDPDG As Integer
dwVendorInfo As Long
End Type

Private Type hostent_async
h_name As Long
h_aliases As Long
h_addrtype As Integer
h_length As Integer
h_addr_list As Long
h_asyncbuffer(MAXGETHOSTSTRUCT) As Byte
End Type

Const IP_STATUS_BASE = 11000
Const IP_SUCCESS = 0
Const IP_BUF_TOO_SMALL = (11000 + 1)
Const IP_DEST_NET_UNREACHABLE = (11000 + 2)
Const IP_DEST_HOST_UNREACHABLE = (11000 + 3)
Const IP_DEST_PROT_UNREACHABLE = (11000 + 4)
Const IP_DEST_PORT_UNREACHABLE = (11000 + 5)
Const IP_NO_RESOURCES = (11000 + 6)
Const IP_BAD_OPTION = (11000 + 7)
Const IP_HW_ERROR = (11000 + 8)
Const IP_PACKET_TOO_BIG = (11000 + 9)
Const IP_REQ_TIMED_OUT = (11000 + 10)
Const IP_BAD_REQ = (11000 + 11)
Const IP_BAD_ROUTE = (11000 + 12)
Const IP_TTL_EXPIRED_TRANSIT = (11000 + 13)
Const IP_TTL_EXPIRED_REASSEM = (11000 + 14)
Const IP_PARAM_PROBLEM = (11000 + 15)
Const IP_SOURCE_QUENCH = (11000 + 16)
Const IP_OPTION_TOO_BIG = (11000 + 17)
Const IP_BAD_DESTINATION = (11000 + 18)
Const IP_ADDR_DELETED = (11000 + 19)
Const IP_SPEC_MTU_CHANGE = (11000 + 20)
Const IP_MTU_CHANGE = (11000 + 21)
Const IP_UNLOAD = (11000 + 22)
Const IP_ADDR_ADDED = (11000 + 23)
Const IP_GENERAL_FAILURE = (11000 + 50)
Const MAX_IP_STATUS = 11000 + 50
Const IP_PENDING = (11000 + 255)
Const PING_TIMEOUT = 200
Const WS_VERSION_REQD = &H101
Const WS_VERSION_MAJOR = WS_VERSION_REQD &H100 And &HFF&
Const WS_VERSION_MINOR = WS_VERSION_REQD And &HFF&
Const MIN_SOCKETS_REQD = 1
Const SOCKET_ERROR = -1
Const INADDR_NONE = &HFFFFFFFF

'Variablen:
'==========

Public Const hostent_size = 16
Public PointerToPointer, IPLong As Long

Dim hostent_async As hostent_async
Dim ICMPOPT As ICMP_OPTIONS

Public Function GetHost(ByVal Host$) As Long
Dim ListAddress As Long
Dim ListAddr As Long
Dim LH&, phe&
Dim Start As Boolean
Dim heDestHost As HOSTENT
Dim addrList&, repIP&

Start = SocketsInitialize
If Start = False Then
GetHost = 0
MsgBox ("Fehler bei der SocketInitialisierung!")
Exit Function
End If

LH = inet_addr(Host$)
repIP = LH
If LH = INADDR_NONE Then
phe = gethostbyname(Host$)
If phe <> 0 Then
CopyMemory heDestHost, ByVal phe, hostent_size
CopyMemory addrList, ByVal heDestHost.hAddrList, 4
CopyMemory repIP, ByVal addrList, heDestHost.hLen
Else
Call MsgBox("GetHostByName lieferte ungültiges Ergebnis!")
GetHost = INADDR_NONE
Exit Function
End If
End If
Form1.Text4.Text = CStr(repIP)
GetHost = repIP
End Function

Public Function GetStatusCode(Status As Long) As String
Dim Msg As String

Select Case Status
Case IP_SUCCESS: Msg = "ip success"
Case IP_BUF_TOO_SMALL: Msg = "ip buf too_small"
Case IP_DEST_NET_UNREACHABLE: Msg = "ip dest net unreachable"
Case IP_DEST_HOST_UNREACHABLE: Msg = "ip dest host unreachable"
Case IP_DEST_PROT_UNREACHABLE: Msg = "ip dest prot unreachable"
Case IP_DEST_PORT_UNREACHABLE: Msg = "ip dest port unreachable"
Case IP_NO_RESOURCES: Msg = "ip no resources"
Case IP_BAD_OPTION: Msg = "ip bad option"
Case IP_HW_ERROR: Msg = "ip hw_error"
Case IP_PACKET_TOO_BIG: Msg = "ip packet too_big"
Case IP_REQ_TIMED_OUT: Msg = "ip req timed out"
Case IP_BAD_REQ: Msg = "ip bad req"
Case IP_BAD_ROUTE: Msg = "ip bad route"
Case IP_TTL_EXPIRED_TRANSIT: Msg = "ip ttl expired transit"
Case IP_TTL_EXPIRED_REASSEM: Msg = "ip ttl expired reassem"
Case IP_PARAM_PROBLEM: Msg = "ip param_problem"
Case IP_SOURCE_QUENCH: Msg = "ip source quench"
Case IP_OPTION_TOO_BIG: Msg = "ip option too_big"
Case IP_BAD_DESTINATION: Msg = "ip bad destination"
Case IP_ADDR_DELETED: Msg = "ip addr deleted"
Case IP_SPEC_MTU_CHANGE: Msg = "ip spec mtu change"
Case IP_MTU_CHANGE: Msg = "ip mtu_change"
Case IP_UNLOAD: Msg = "ip unload"
Case IP_ADDR_ADDED: Msg = "ip addr added"
Case IP_GENERAL_FAILURE: Msg = "ip general failure"
Case IP_PENDING: Msg = "ip pending"
Case PING_TIMEOUT: Msg = "ping timeout"
Case Else: Msg = "unknown msg returned"
End Select

GetStatusCode = CStr(Status) & " [ " & Msg & " ]"
End Function

Private Function HiByte(ByVal wParam As Integer)
HiByte = wParam &H100 And &HFF&
End Function

Private Function LoByte(ByVal wParam As Integer)
LoByte = wParam And &HFF&
End Function

Public Function Ping(szAddress As String, _
ECHO As ICMP_ECHO_REPLY) As Long

Dim hPort As Long
Dim dwAddress As Long
Dim sDataToSend As String
Dim iOpt As Long
Dim A

sDataToSend = Trim$(Form1.Text3.Text)
dwAddress = GetHost(szAddress)

hPort = IcmpCreateFile()

If IcmpSendEcho(hPort, dwAddress, sDataToSend, Len(sDataToSend), _
0, ECHO, Len(ECHO), PING_TIMEOUT) Then

Ping = ECHO.RoundTripTime
Else: Ping = ECHO.Status * -1
End If

Call IcmpCloseHandle(hPort)
A = SocketsCleanup
End Function

Private Function AddressStringToLong(ByVal Tmp As String) As Long
Dim i As Integer
Dim parts(1 To 4) As String

i = 0
While InStr(Tmp, ".") > 0
i = i + 1
parts(i) = Mid(Tmp, 1, InStr(Tmp, ".") - 1)
Tmp = Mid(Tmp, InStr(Tmp, ".") + 1)
Wend

i = i + 1
parts(i) = Tmp

If i <> 4 Then
AddressStringToLong = 0
Exit Function
End If

AddressStringToLong = Val("&H" & Right("00" & Hex(parts(4)), 2) & _
Right("00" & Hex(parts(3)), 2) & _
Right("00" & Hex(parts(2)), 2) & _
Right("00" & Hex(parts(1)), 2))
End Function

Private Function SocketsCleanup() As Boolean
Dim X As Long

X = WSACleanup()
If X <> 0 Then
Call MsgBox("Windows Sockets error " & Trim$(Str$(X)) & _
" occurred in Cleanup.", vbExclamation)
SocketsCleanup = False
Else
SocketsCleanup = True
End If
End Function

Private Function SocketsInitialize() As Boolean
Dim WSAD As WSAData
Dim X As Integer
Dim szLoByte As String, szHiByte As String, szBuf As String

X = WSAStartup(WS_VERSION_REQD, WSAD)
If X <> 0 Then
Call MsgBox("Windows Sockets for 32 bit Windows " & _
"environments is not successfully responding.")
SocketsInitialize = False
Exit Function
End If

SocketsInitialize = True
End Function
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Frage zu einem Tipp66Xelion01.04.02 17:37
Übersetzung ....351unbekannt01.04.02 19:09
Re: Übersetzung ....33Xelion01.04.02 19:19
Nein.291unbekannt01.04.02 19:28
Re: Nein.31Xelion01.04.02 19:33
Re: Nein.306unbekannt01.04.02 19:45
Re: Nein.31Xelion01.04.02 19:46
Poste mal, was Du bis jetzt hast. (oT)282unbekannt01.04.02 19:49
Re: Poste mal, was Du bis jetzt hast. (oT)39Xelion01.04.02 19:55
Wo soll der Computername sein? Ich finde da nichts. Niergend...238unbekannt01.04.02 20:28
Re: Wo soll der Computername sein? Ich finde da nichts. Nier...46Xelion01.04.02 20:37
Na dann hast Du die Frage aber falsch formuliert.255unbekannt01.04.02 20:43
Re: Na dann hast Du die Frage aber falsch formuliert.30Xelion01.04.02 21:00
Oh Mann, gestern hatte ich genau das noch unter den Fingern....253unbekannt01.04.02 21:02
Eine DLL ... *grübel* aber in welcher? Fällt mir bestimmt no...223unbekannt01.04.02 21:12
hoff hoff32Xelion01.04.02 21:24
Ist es dir noch mal eingefallen??30Xelion02.04.02 14:42
Re: Ist es dir noch mal eingefallen??22Xelion02.04.02 20:32
Uff, mir fällt's nicht mehr ein 270unbekannt02.04.02 20:44
Re: Uff, mir fällt's nicht mehr ein 163Xelion02.04.02 20:52
Found aber hallo, klar Winsock.DLL ... näheres gleich.....297unbekannt02.04.02 20:52
*Lol* gefunden bei Allapi-Net ... so long:413unbekannt02.04.02 21:00
Re: *Lol* gefunden bei Allapi-Net ... so long:24Xelion02.04.02 21:06
fehler31Xelion02.04.02 21:18
kann mir vielleicht jemand helfen...26Xelion03.04.02 18:09
Re: kann mir vielleicht jemand helfen...294ModeratorDieter03.04.02 18:19
Re: kann mir vielleicht jemand helfen...25Xelion03.04.02 18:22

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel