В Win9x незнаю  если найдёшь, напиши плз.) А в NT_хах (Win2k, WinXp) примерно так: 'На форме: баттон и 2 textbox-a 'один для имени компа (text1) , второй для текста Option Explicit Private Declare Function NetMessageBufferSend Lib "Netapi32.dll" (ByVal sServerName$, ByVal sMsgName$, ByVal sFromName$, ByVal sMessageText$, ByVal lBufferLength& As Long Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long Dim UserName As String, CompName As String Private Sub Command1_Click()
Dim lReturnCode As Long Dim sUnicodeToName As String Dim sUnicodeFromName As String Dim sUnicodeMessage As String Dim lMessageLength As Long sUnicodeFromName = StrConv(CompName, vbUnicode) sUnicodeToName = StrConv(Text1.Text, vbUnicode) sUnicodeMessage = StrConv(Text2.Text + vbCrLf & vbCrLf & vbCrLf & "_______________________________________" & vbCrLf & UserName, vbUnicode) lMessageLength = Len(sUnicodeMessage)
lReturnCode = NetMessageBufferSend("", sUnicodeToName, sUnicodeFromName, sUnicodeMessage, lMessageLength) If lReturnCode = 0 Then MsgBox "Ваше сообщение отправленно!", vbInformation, Me.Caption Else MsgBox "Ваше сообщение не отправленно! Ошибка : " + CStr(lReturnCode) End If End Sub
Private Sub Form_Load() Dim lpBuff As String * 25 Dim ret As Long Dim strBuffer As String Dim lngBufSize As Long Dim lngStatus As Long ret = GetUserName(lpBuff, 25) UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1) lngBufSize = 255 strBuffer = String$(lngBufSize, " ") lngStatus = GetComputerName(strBuffer, lngBufSize) If lngStatus <> 0 Then CompName = Left(strBuffer, lngBufSize) End If End Sub З.Ы. код не мой, а кто автор я не помню (кде-то когда-то нашёл ), но работает. Правда только на Win2k & XP
Ответить
|