-
128 Byte Truncation problem with Mailslots and Net Send <user> in WinNT...
I have a problem trying to figure out why this is truncating the message at
128 bytes. If I use NET SEND <USER> Message at the command prompt, I can
have a message greater than 128 Bytes. I can also do the same with
NetMessageBufferSend, but the problem is that it is only availible on a
WinNT machine. What are these Network functions doing that make this
possible?
I am trying to use a platform independant solution of the
\\MachineName\Mailslot\messngr which will send a message to the MachineName.
This works fine until the message exceeds 128 bytes. The following code
duplicates the problem.
Thanks in advance,
Wade Balzer
Option Explicit
Private Const OPEN_EXISTING = 3
Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" ( _
ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByVal lpSecurityAttributes As Long, _
ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, _
ByVal hTemplateFile As Long) As Long
Private Declare Function WriteFile Lib "kernel32" ( _
ByVal hFile As Long, _
ByVal lpBuffer As Any, _
ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, _
ByVal lpOverlapped As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long
Public Sub Main()
Dim FromWho$, ToMachineName$, MailSlot$, msHnd&, msgtxt$, msg$, rc&,
byteswritten&
FromWho = "MyName"
ToMachineName = "DEV01" 'Name of the Computer
MailSlot = "\\" & ToMachineName & "\Mailslot\messngr"
msg = "This is some very long message that is over 128 bytes long. " &
vbCrLf & _
"If this message were any shorter I could not send all the
information " & vbCrLf & _
"that I need to to the user at the Machine that I am trying to send
this " & vbCrLf & _
"message to. I hope someone can help me fix this problem."
Debug.Print "Message is " & Len(msg) & " characters long."
msgtxt = FromWho & Chr(0) & ToMachineName & Chr(0) & msg & Chr(0)
msHnd = CreateFile(MailSlot, _
GENERIC_WRITE, _
FILE_SHARE_READ, _
0, _
OPEN_EXISTING, _
FILE_ATTRIBUTE_NORMAL, _
0)
If msHnd = -1 Then
'error
MsgBox "Error creating mailslot"
Exit Sub
End If
rc = WriteFile(msHnd, msgtxt, Len(msgtxt), byteswritten, 0)
If rc = 0 Then
'error
MsgBox "Problem writing to mailslot"
End If
rc = CloseHandle(msHnd)
msHnd = 0
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks