Programación General > Delphi
Net Send
(1/1)
Isnel:
Quiero hacer un programa para enviar mensajes desde un servidor a las demas maquinas de la red (algo parecido a Net Send), pero no se que componente o función usar. No quiero usar los componentes de Indy porque necesitaria un programa cliente en cada maquina.
Buscando encontré la API NetMessageBufferSend, pero no se como usarla (?en que DLL está? y ?Cómo importarla?).
Aquí les mando lo que encontré en la ayuda. Gracias de antemano
The NetMessageBufferSend function sends a buffer of information to a registered message alias.
Security Requirements
No special group membership is required to execute NetMessageBufferSend on a LAN Manager or Windows NT system. Admin, Accounts, Print, or Server operator group membership is required to successfully execute NetMessageBufferSend on a remote server.
NET_API_STATUS NetMessageBufferSend(
LPTSTR servername,
LPTSTR msgname,
LPTSTR fromname,
LPBYTE buf,
DWORD buflen
);
Parameters
servername
Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.
msgname
Pointer to a Unicode string containing the message name to which the message buffer should be sent.
fromname
Pointer to a Unicode string containing the message name sending the information. The fromname parameter is new for Windows networking. This parameter is needed for sending interrupting messages from the computer name rather than the logged on user. If NULL is specified, the message is sent from the logged-on user as with LAN Manager 2.x.
buf
Pointer to a buffer of message text.
buflen
The length, in bytes, of the message text in buf.
See Also
NetMessageNameAdd, NetMessageNameDel, NetMessageNameEnum, NetMessageNameGetInfo
Isnel:
Ya resolví. Aquí va la solución para los que estén interesados
--- Código: Text ---function NetMessageBufferSend(ServerName: LPWSTR; MsgName: LPWSTR; FromName: LPWSTR; Buf: LPWSTR; BufLen: DWORD): DWORD; stdcall; external 'NetApi32.dll' name 'NetMessageBufferSend'; function NetSend(destino, mensaje: String): Cardinal;var wsMensaje, wsDestino: WideString; longMensaje: Integer;begin wsMensaje := mensaje; wsDestino := destino; longMensaje := Length(wsMensaje)*2; Result := NetMessageBufferSend(nil, PWideChar(wsDestino), nil, PWideChar(wsMensaje), longMensaje);end; procedure TForm1.Button1Click(Sender: TObject);var Error: Cardinal;begin Error := NetSend(Destino.Text, Mensaje.Text); if Error = 0 then ShowMessage('Mensaje enviado') else ShowMessage('Mensaje no enviado, error: ' + IntToStr(Error));end; end.
Navegación
Ir a la versión completa