• Lunes 29 de Abril de 2024, 15:58

Autor Tema:  Net Send  (Leído 1386 veces)

Isnel

  • Miembro activo
  • **
  • Mensajes: 29
    • Ver Perfil
Net Send
« en: Jueves 16 de Noviembre de 2006, 16:01 »
0
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

  • Miembro activo
  • **
  • Mensajes: 29
    • Ver Perfil
Re: Net Send
« Respuesta #1 en: Jueves 16 de Noviembre de 2006, 18:32 »
0
Ya resolví. Aquí va la solución para los que estén interesados

Código: Text
  1. function NetMessageBufferSend(ServerName: LPWSTR;
  2.                               MsgName: LPWSTR;
  3.                               FromName: LPWSTR;
  4.                               Buf: LPWSTR;
  5.                               BufLen: DWORD): DWORD; stdcall;
  6.                               external 'NetApi32.dll' name 'NetMessageBufferSend';
  7.  
  8. function NetSend(destino, mensaje: String): Cardinal;
  9. var
  10.   wsMensaje, wsDestino: WideString;
  11.   longMensaje: Integer;
  12. begin
  13.   wsMensaje := mensaje;
  14.   wsDestino := destino;
  15.   longMensaje := Length(wsMensaje)*2;
  16.   Result := NetMessageBufferSend(nil, PWideChar(wsDestino), nil,
  17.                                  PWideChar(wsMensaje), longMensaje);
  18. end;
  19.  
  20.  
  21. procedure TForm1.Button1Click(Sender: TObject);
  22. var
  23.  Error: Cardinal;
  24. begin
  25.   Error := NetSend(Destino.Text, Mensaje.Text);
  26.   if Error = 0 then
  27.      ShowMessage('Mensaje enviado')
  28.   else
  29.      ShowMessage('Mensaje no enviado, error: ' + IntToStr(Error));
  30. end;
  31.  
  32. end.
  33.