VB如何实现信使服务的功能,即net send的功能,向局域网电脑发送Message消息

解决方案 »

  1.   

    试试NetMessageBufferSend'模块
    Public Const NERR_Success As Long = 0&Public Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" (Server As Any, yToName As Byte, yFromName As Any, yMsg As Byte, ByVal lSize As Long) As Long
    Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As LongPublic Const MAX_RESOURCES = 256
    Public Const NOT_A_CONTAINER = -1
    Public Function Sendmsg(strTo As String, strFrom As String, strMessage As String) As Boolean
        Dim bytTo() As Byte
        Dim bytFrom() As Byte
        Dim bytMsg() As Byte
        Dim Name As String, Length As Long
        Length = 255
        Name = String(Length, 0)
        GetComputerName Name, Length
        Name = Left(Name, Length)
        bytTo = strTo & vbNullChar
        bytFrom = IIf(strFrom = "", Name, strFrom) & vbNullChar
        bytMsg = strMessage & vbNullChar
        Sendmsg = (NetMessageBufferSend(ByVal 0&, bytTo(0), ByVal 0&, bytMsg(0), UBound(bytMsg)) = NERR_Success)
    End Function
    '调用位置
    Private Sub Command1_Click()
        Sendmsg "发送机器名称,可以不写,默认是本机", "目的地机器名称", "消息内容"
    End Sub
      

  2.   

    简单点的就这样:shell "net send 192.168.0.1 sdfsdf"
      

  3.   

    shell "cmd /c net send ...."
      

  4.   

    我用shell "cmd/c net send"
    的方法写了一个发送消息的程序,打算进一步改成用api函数的,估计速度能快一些,如果需要的话,何以给你
    [email protected]