Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1
    Utente di HTML.it L'avatar di Teddy
    Registrato dal
    Dec 2001
    Messaggi
    178

    Programma per inviare messaggi in rete

    Ciao a tutti!
    Ho realizzato un piccolo programma in VB che serve a spedire dei messaggi (attraverso le messagebox) ad altri utenti collegati in una LAN. Il programma non fa altro che richiamare il "send message" di windows e passargli la stringa del messaggio. Ovviamente funziona solo con WIN 2000 e WIN XP che hanno questo servizio. Con WIN98 funziona solo se l'utente ha winpopup in esecuzione!
    Cme posso fare affinchè il messaggio venga visualizzato in qualsiasi PC a prescindere dal sistema operativo???
    Qualcuno sa darmi un idea???
    Ciao grazie!
    Grazie e ciao a tutti

  2. #2
    Ho fatto un piccolo programma di messaggistica che prevede l'archiviazione dei messaggi su server con informazioni del tipo:

    - inviato da
    - destinato a
    - messaggio

    con i dati prelevati dai vari login di accesso alla rete.

    Ho fatto anche un programma che gira in background (avviato in esecuzione automatica su ogni pc) che interroga l'archivo ogni minuto per vedere se ci sono messaggi con medesimo login e imposta un flag una volta intercettato il messaggio per l'avvenuta lettura.

    Penso ci siano idee più sofisticate ... interessano anche a me.

    Ciao

  3. #3
    Utente di HTML.it L'avatar di Teddy
    Registrato dal
    Dec 2001
    Messaggi
    178
    Vorrei realizzare una cosa semplice ...
    Innanzitutto evitare di fare un programma che giri in background, seconda cosa ho tutti gli indirizzi IP delle macchine collegate alla nostra LAN. Ho soltanto la necessità di inviare delle comunicazioni a tutti gli IP in rete... qualcuno ha un idea???
    Ciao
    Grazie e ciao a tutti

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2001
    Messaggi
    1,003
    Originariamente inviato da Teddy
    Ho soltanto la necessità di inviare delle comunicazioni a tutti gli IP in rete... qualcuno ha un idea???
    Ciao
    manda il messaggio in broadcast



  5. #5
    se vuoi io posso passarti una sub per fare ping ad un determinato cpu

  6. #6
    Utente di HTML.it L'avatar di Teddy
    Registrato dal
    Dec 2001
    Messaggi
    178
    Originariamente inviato da tia86
    manda il messaggio in broadcast


    Mi puoi spiegare meglio?
    Grazie!
    Grazie e ciao a tutti

  7. #7
    con questa sub fai ping ad un computer, ovvero (caspita ma non lo sai? ) verifichi che il computer sia in rete e accesso


    Il ping lo si fa all' indirizzo ip

  8. #8
    eccoti la sub


    ************************************************** ********************
    codice:
    Private Type ICMP_OPTIONS
        Ttl             As Byte
        Tos             As Byte
        Flags           As Byte
        OptionsSize     As Byte
        OptionsData     As Long
    End Type
    Private 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
    Private Const MAX_WSADescription = 256
    Private Const MAX_WSASYSStatus = 128
    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
    '//
    '// Win32s
    '//
    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" (ByVal szHost As String, dwHostLen As Long) As Long
    Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal szHost As String) As Long
    Private Declare Sub RtlMoveMemory Lib "kernel32" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
    '//
    '// Constants
    '//
    Private Const IP_STATUS_BASE = 11000
    Private Const IP_SUCCESS = 0
    Private Const IP_BUF_TOO_SMALL = (11000 + 1)
    Private Const IP_DEST_NET_UNREACHABLE = (11000 + 2)
    Private Const IP_DEST_HOST_UNREACHABLE = (11000 + 3)
    Private Const IP_DEST_PROT_UNREACHABLE = (11000 + 4)
    Private Const IP_DEST_PORT_UNREACHABLE = (11000 + 5)
    Private Const IP_NO_RESOURCES = (11000 + 6)
    Private Const IP_BAD_OPTION = (11000 + 7)
    Private Const IP_HW_ERROR = (11000 + 8)
    Private Const IP_PACKET_TOO_BIG = (11000 + 9)
    Private Const IP_REQ_TIMED_OUT = (11000 + 10)
    Private Const IP_BAD_REQ = (11000 + 11)
    Private Const IP_BAD_ROUTE = (11000 + 12)
    Private Const IP_TTL_EXPIRED_TRANSIT = (11000 + 13)
    Private Const IP_TTL_EXPIRED_REASSEM = (11000 + 14)
    Private Const IP_PARAM_PROBLEM = (11000 + 15)
    Private Const IP_SOURCE_QUENCH = (11000 + 16)
    Private Const IP_OPTION_TOO_BIG = (11000 + 17)
    Private Const IP_BAD_DESTINATION = (11000 + 18)
    Private Const IP_ADDR_DELETED = (11000 + 19)
    Private Const IP_SPEC_MTU_CHANGE = (11000 + 20)
    Private Const IP_MTU_CHANGE = (11000 + 21)
    Private Const IP_UNLOAD = (11000 + 22)
    Private Const IP_ADDR_ADDED = (11000 + 23)
    Private Const IP_GENERAL_FAILURE = (11000 + 50)
    Private Const MAX_IP_STATUS = 11000 + 50
    Private Const IP_PENDING = (11000 + 255)
    Private Const PING_TIMEOUT = 200
    Private Const WS_VERSION_REQD = &H101
    Private Const WS_VERSION_MAJOR = WS_VERSION_REQD \ &H100 And &HFF&
    Private Const WS_VERSION_MINOR = WS_VERSION_REQD And &HFF&
    Private Const MIN_SOCKETS_REQD = 1
    Private Const SOCKET_ERROR = -1
    Public Function GetIPAddress() As String
        Dim szHost As String * 256
        Dim lpHost As Long
        Dim HOST As HOSTENT
        Dim dwIPAddr As Long
        Dim tmpIPAddr() As Byte
        Dim i As Integer
        Dim szIPAddr As String
        
        If Not SocketsInitialize() Then
            GetIPAddress = ""
            Exit Function
        End If
        
        If gethostname(szHost, 256) = SOCKET_ERROR Then
            GetIPAddress = ""
            MsgBox "Windows Sockets error " & Str(WSAGetLastError()) & " has occurred.  Unable to successfully get Host Name.", vbExclamation
            SocketsCleanup
            Exit Function
        End If
        
        szHost = Trim$(szHost)
        lpHost = gethostbyname(szHost)
        
        If lpHost = 0 Then
            GetIPAddress = ""
            MsgBox "Windows Sockets are not responding.  Unable to successfully get Host Name.", vbExclamation
            SocketsCleanup
            Exit Function
        End If
        
        RtlMoveMemory HOST, lpHost, Len(HOST)
        RtlMoveMemory dwIPAddr, HOST.hAddrList, 4
        
        ReDim tmpIPAddr(1 To HOST.hLen)
        RtlMoveMemory tmpIPAddr(1), dwIPAddr, HOST.hLen
        
        For i = 1 To HOST.hLen
            szIPAddr = szIPAddr & tmpIPAddr(i) & "."
        Next
        
        GetIPAddress = Mid$(szIPAddr, 1, Len(szIPAddr) - 1)
        SocketsCleanup
        
    End Function
    
    Public Function GetIPHostName() As String
        Dim szHost As String * 256
        
        If Not SocketsInitialize() Then
            GetIPHostName = ""
            Exit Function
        End If
        
        If gethostname(szHost, 256) = SOCKET_ERROR Then
            GetIPHostName = ""
            MsgBox "Windows Sockets error " & Str(WSAGetLastError()) & " has occurred.  Unable to successfully get Host Name.", vbExclamation
            SocketsCleanup
            Exit Function
        End If
        
        '// GetIPHostName = Trim$(szHost)
        GetIPHostName = Left$(szHost, InStr(szHost, Chr(0)) - 1)
        SocketsCleanup
    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) As Long
        Dim hPort As Long, dwAddress As Long, szMessage As String
        Dim x As Long
        Dim ECHO As ICMP_ECHO_REPLY
        
        szMessage = "Echo This."
        dwAddress = AddressStringToLong(szAddress)
        
        hPort = IcmpCreateFile()
        x = IcmpSendEcho(hPort, dwAddress, szMessage, Len(szMessage), 0, ECHO, Len(ECHO), PING_TIMEOUT)
        If x = 0 Then
            Ping = ECHO.status * -1
        Else
            ' the ping succeeded,
            '   .Status will be 0
            '   .RoundTripTime is the time in ms for the ping to complete, .Data is the data returned (NULL terminated)
            '   .Address is the Ip address that actually replied
            '   .DataSize is the size of the string in .Data
            Ping = ECHO.RoundTripTime
        End If
        
        x = IcmpCloseHandle(hPort)
        
    End Function
    
    Function AddressStringToLong(szAddress As String) As Long
        Dim szTmp As String, i As Integer, Octets(1 To 4) As String
        
        szTmp = szAddress
        i = 0
        
        While InStr(szTmp, ".") > 0
            i = i + 1
            Octets(i) = Mid(szTmp, 1, InStr(szTmp, ".") - 1)
            szTmp = Mid(szTmp, InStr(szTmp, ".") + 1)
        Wend
        
        i = i + 1
        Octets(i) = szTmp
        
        If i <> 4 Then
            AddressStringToLong = 0
            Exit Function
        End If
        
        AddressStringToLong = Val("&H" & Right("00" & Hex(Octets(4)), 2) & Right("00" & Hex(Octets(3)), 2) & Right("00" & Hex(Octets(2)), 2) & Right("00" & Hex(Octets(1)), 2))
        
    End Function
    
    Public Function SocketsCleanup() As Boolean
        Dim x As Long
        
        x = WSACleanup()
        
        If x <> 0 Then
            MsgBox "Windows Sockets error " & Trim$(Str$(x)) & " occurred in Cleanup.", vbExclamation
            SocketsCleanup = False
        Else
            SocketsCleanup = True
        End If
        
    End Function
    
    Public 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
            MsgBox "Windows Sockets for 32 bit Windows environments is not successfully responding.", vbExclamation
            SocketsInitialize = False
            Exit Function
        End If
        
        If LoByte(WSAD.wVersion) < WS_VERSION_MAJOR Or (LoByte(WSAD.wVersion) = WS_VERSION_MAJOR And HiByte(WSAD.wVersion) < WS_VERSION_MINOR) Then
            szHiByte = Trim$(Str$(HiByte(WSAD.wVersion)))
            szLoByte = Trim$(Str$(LoByte(WSAD.wVersion)))
            szBuf = "Windows Sockets Version " & szLoByte & "." & szHiByte
            szBuf = szBuf & " is not supported by Windows Sockets for 32 bit Windows environments."
            MsgBox szBuf, vbExclamation
            SocketsInitialize = False
            Exit Function
        End If
        
        If WSAD.wMaxSockets < MIN_SOCKETS_REQD Then
            szBuf = "This application requires a minimum of " & Trim$(Str$(MIN_SOCKETS_REQD)) & " supported sockets."
            MsgBox szBuf, vbExclamation
            SocketsInitialize = False
            Exit Function
        End If
        
        SocketsInitialize = True
        
    End Function
    
    Public Function DetermineIP(szTmp As String) As Boolean
        On Error GoTo Handler
        Dim i As Integer
        Dim nOctet As Integer
        While InStr(szTmp, ".") > 0
            i = i + 1
            nOctet = Mid(szTmp, 1, InStr(szTmp, ".") - 1)
            szTmp = Mid(szTmp, InStr(szTmp, ".") + 1)
        Wend
        If (i <> 3) Then
            DetermineIP = False
        Else
            DetermineIP = True
        End If
        Exit Function
        Handler:
        DetermineIP = False
    End Function
    ************************************************** ********************

  9. #9
    Utente di HTML.it
    Registrato dal
    Jul 2001
    Messaggi
    1,003
    Originariamente inviato da Teddy
    Mi puoi spiegare meglio?
    Grazie!
    con ipconfig (da dos) guardi il tuo ip e la subnet mask della rete interna
    se x es. hai IP: 192.168.1.1 e subnet mask 255.255.255.0 basta ke mandi il messaggio all'IP 192.168.1.255 ke tutti i pc della lan lo ricevono




  10. #10
    Utente di HTML.it L'avatar di Teddy
    Registrato dal
    Dec 2001
    Messaggi
    178
    Il problema non è questo ...
    se uso net send per spedire un unico messaggio a tutti gli IP collegati nella LAN, solo coloro che avranno winNT, 2000, XP, visualizzeranno il messaggio; chi avrà WIN98 non vedrà niente!
    Vorrei che il messaggio venga spedito a tutti a prescindere dal sistema operativo in uso.
    Come posso risolvere???
    Grazie e ciao a tutti

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.