Mensajes entre usuarios con NetApi32.dll
Publicado por Pere (150 intervenciones) el 05/02/2007 09:24:47
Un saludo a todos.
Tengo un pequeño programa de mensajería, entre usuarios de la empresa, que funciona perfectamente con XP sp1 pero no con XP sp2. Usa la función NetSendMessage de la
Api NetApi32.dll. Supongo que el sp2 debe bloquear algún puerto pero en el código
del programa no hay referencia al mismo.
Desde un formulario:
Dim ret as Long
ret = NetSendMessage(Text1.Text, Texto)
donde Text1.text contiene el nombre del usuario que ha iniciado la sesión y Texto el
mensaje a enviar.
En un módulo:
Private Declare Function NetMessageBufferSend Lib "NetApi32.dll" _
(ByVal servername As String, _
ByVal msgname As String, _
ByVal fromname As String, _
ByVal Buffer As String, _
ByVal BufSize As Long) As Long
Private Const NERR_SUCCESS As Long = 0
Private Const NERR_BASE As Long = 2100
Private Const NERR_NetworkError As Long = (NERR_BASE + 36)
Private Const NERR_NameNotFound As Long = (NERR_BASE + 173)
Private Const NERR_UseNotFound As Long = (NERR_BASE + 150)
Private Const ERROR_ACCESS_DENIED As Long = 5
Private Const ERROR_BAD_NETPATH As Long = 53
Private Const ERROR_NOT_SUPPORTED As Long = 50
Private Const ERROR_INVALID_PARAMETER As Long = 87
Private Const ERROR_INVALID_NAME As Long = 123
Public Function NetSendMessage(ByVal sSendTo As String, ByVal sMessage As String) As Long
Dim ret As Long
sSendTo = StrConv(sSendTo, vbUnicode)
sMessage = StrConv(sMessage, vbUnicode)
NetSendMessage = NetMessageBufferSend(vbNullString, sSendTo, vbNullString, _
sMessage, Len(sMessage))
End Function
El error se produce en: NERR_NameNotFound
Gracias por vuestro tiempo.
Tengo un pequeño programa de mensajería, entre usuarios de la empresa, que funciona perfectamente con XP sp1 pero no con XP sp2. Usa la función NetSendMessage de la
Api NetApi32.dll. Supongo que el sp2 debe bloquear algún puerto pero en el código
del programa no hay referencia al mismo.
Desde un formulario:
Dim ret as Long
ret = NetSendMessage(Text1.Text, Texto)
donde Text1.text contiene el nombre del usuario que ha iniciado la sesión y Texto el
mensaje a enviar.
En un módulo:
Private Declare Function NetMessageBufferSend Lib "NetApi32.dll" _
(ByVal servername As String, _
ByVal msgname As String, _
ByVal fromname As String, _
ByVal Buffer As String, _
ByVal BufSize As Long) As Long
Private Const NERR_SUCCESS As Long = 0
Private Const NERR_BASE As Long = 2100
Private Const NERR_NetworkError As Long = (NERR_BASE + 36)
Private Const NERR_NameNotFound As Long = (NERR_BASE + 173)
Private Const NERR_UseNotFound As Long = (NERR_BASE + 150)
Private Const ERROR_ACCESS_DENIED As Long = 5
Private Const ERROR_BAD_NETPATH As Long = 53
Private Const ERROR_NOT_SUPPORTED As Long = 50
Private Const ERROR_INVALID_PARAMETER As Long = 87
Private Const ERROR_INVALID_NAME As Long = 123
Public Function NetSendMessage(ByVal sSendTo As String, ByVal sMessage As String) As Long
Dim ret As Long
sSendTo = StrConv(sSendTo, vbUnicode)
sMessage = StrConv(sMessage, vbUnicode)
NetSendMessage = NetMessageBufferSend(vbNullString, sSendTo, vbNullString, _
sMessage, Len(sMessage))
End Function
El error se produce en: NERR_NameNotFound
Gracias por vuestro tiempo.
Valora esta pregunta


0