Logo
English Russian German French Spanish Italian
contact usprivacy
   Support Forums
chart
• Adjust flexgrid cell
• Animation
• Centering form text
• Coffee machine
• Creating fileshares
• Creating shortcuts
• Custom buttons
• Directory browser
• Disable mouse events
• File search by ext
• File transfer
• File watcher
• Formatting flexgrid
• Get Content Type
• Get HTML source
• Get modem port
• HTTP proxy
• ipconfig
• Large file split/merge
• MAPI
• MCI Sound Player
• Menu with images
• MP3 normalizer
• Net Send
• Netstat 2000
• No duplicate entries
• Outlook Address Book
• Set font color
• Shapes
• SOAP test
• Text-to-image
• Text file viewer
• Text find/replace
• UPS component
• View NT groups
• Word template
• Writing DNS control
    • Using DNS control
• Writing SMTP control
    • Sending email
    • Mailing list
• Writing WhoIs control
    • Using WhoIs control
• View HTML source
OISV - Organization of Independent Software Vendors - Contributing Member
VB projects - Net Send

Description: VB implementation of "net send" command
Minimum requirements: VB6
Download: source code
Screenshot:
VB projects - Net Send
Project: EXE
Controls: CommandButton cmdSend (Caption = "Send"), ListBox lst, TextBox txtMsg,
Additional references: none
Code:
Option Explicit

Const ERROR_SUCCESS = 0
Const ERROR_MORE_DATA = 234
Const SV_TYPE_SERVER = &H2
Const SIZE_SI_101 = 24

Private Type SERVER_INFO_101
  dwPlatformId As Long
  lpszServerName As Long
  dwVersionMajor As Long
  dwVersionMinor As Long
  dwType As Long
  lpszComment As Long
End Type

Private Declare Function NetServerEnum Lib "netapi32.dll" (ByVal servername As String, _
  ByVal level As Long, buffer As Long, ByVal prefmaxlen As Long, entriesread As Long, _
  totalentries As Long, ByVal servertype As Long, ByVal domain As String, resumehandle As Long) As Long

Private Declare Function NetApiBufferFree Lib "netapi32.dll" (BufPtr As Any) As Long
Private Declare Sub RtlMoveMemory Lib "KERNEL32" _
  (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Function lstrcpyW Lib "KERNEL32" _
  (ByVal lpszDest As String, ByVal lpszSrc As Long) As Long

Private Const NERR_Success As Long = 0&
Private Const NERR_BASE = 2100
Private Const NERR_NameNotFound = NERR_BASE + 173
Private Const NERR_NetworkError = NERR_BASE + 36
Private Const ERROR_ACCESS_DENIED = 5
Private Const ERROR_INVALID_PARAMETER = 87
Private Const ERROR_NOT_SUPPORTED = 50

Private Declare Function NetMessageBufferSend Lib "netapi32.dll" (servername As Any, _
  msgname As Byte, fromname As Any, buf As Byte, ByVal buflen As Long) As Long

Private Sub cmdSend_Click() Dim nRet As Long Dim sTo() As Byte Dim sMsg() As Byte sTo = lst.List(lst.ListIndex) & Chr(0) sMsg = txtMsg & Chr(0) nRet = NetMessageBufferSend(ByVal 0, sTo(0), ByVal 0, sMsg(0), UBound(sMsg)) Select Case nRet Case NERR_Success: MsgBox "Success" Case NERR_NameNotFound: MsgBox "NameNotFound" Case NERR_NetworkError: MsgBox "NetworkError" Case ERROR_ACCESS_DENIED: MsgBox "ACCESS_DENIED" Case ERROR_INVALID_PARAMETER: MsgBox "INVALID_PARAMETER" Case ERROR_NOT_SUPPORTED: MsgBox "NOT_SUPPORTED" Case Else: MsgBox "Unexpected error" End Select End Sub
Private Function PointerToString(lpszString As Long) As String Dim lpszStr1 As String, lpszStr2 As String, nRet As Long lpszStr1 = String(1000, "*") nRet = lstrcpyW(lpszStr1, lpszString) lpszStr2 = (StrConv(lpszStr1, vbFromUnicode)) PointerToString = Left(lpszStr2, InStr(lpszStr2, Chr$(0)) - 1) End Function
Private Sub Form_Load() Dim pszServer As String, pszDomain As String Dim nLevel As Long, i As Long, BufPtr As Long, TempBufPtr As Long Dim nPrefMaxLen As Long, nEntriesRead As Long, nTotalEntries As Long Dim nServerType As Long, nResumeHandle As Long, nRet As Long Dim ServerInfo As SERVER_INFO_101 nLevel = 101 BufPtr = 0 nPrefMaxLen = &HFFFFFFFF nEntriesRead = 0 nTotalEntries = 0 nServerType = SV_TYPE_SERVER nResumeHandle = 0 Do nRet = NetServerEnum(pszServer, nLevel, BufPtr, nPrefMaxLen, nEntriesRead, _ nTotalEntries, nServerType, pszDomain, nResumeHandle) If ((nRet = ERROR_SUCCESS) Or (nRet = ERROR_MORE_DATA)) And (nEntriesRead > 0) Then TempBufPtr = BufPtr For i = 1 To nEntriesRead RtlMoveMemory ServerInfo, TempBufPtr, SIZE_SI_101 lst.AddItem PointerToString(ServerInfo.lpszServerName) TempBufPtr = TempBufPtr + SIZE_SI_101 Next i Else MsgBox "NetServerEnum failed: " & nRet End If NetApiBufferFree (BufPtr) Loop While nEntriesRead < nTotalEntries End Sub

Copyright © 1996-2010 OstroSoft. All rights reserved. info@ostrosoft.com