Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Send message to another computer API calls

Posted on 1998-12-08
15
Medium Priority
?
221 Views
Last Modified: 2010-04-04
How can i send message to another computer to remind the person about something? Is this API Calls ( Do you have some code ) Thanks!!
0
Comment
Question by:emiltor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 3

Expert Comment

by:williams2
ID: 1349899
Nope! It is either DCOM, UDP, IPX, TCPIP etc.

If you are to setup a server through a Local Area Network, you should use either DCOM (Distributed COM) or UDP (User Datagram Protocol)

Another and more secure way, is to make the client do a TCP/IP connection to the server at startup. Afterwards, it's very easy to control events and dataparsing. I can give you bright examples of this.

Which version of Delphi have you got?

regards,
Williams
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1349900
Odd - I always thought the U in UDP was for Unreliable in that the protocol does not in fact gurantee delivery of the packet. (at least it is in the Unix world...)

Cheers,

Raymond.
0
 
LVL 7

Accepted Solution

by:
BlackMan earned 200 total points
ID: 1349901
There is the good ol' WinPopup, which uses Mailslots. There is a Delphi implementation of WinPopup, including source, at http://djernaes.dk/martin/winpopup.html
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:williams2
ID: 1349902
Hi Raymond!

So did I, until I got corrected by Andrew S. Tannenbaum in his book "Computer Networks"

BlackMan is right, I guess. This must be the easiest way to do this.

Cheers,
Williams
0
 

Author Comment

by:emiltor
ID: 1349903
I have Delphi 3.0.1 Client/Server
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1349904
You can also use NetMessageBufferSend, this is really easy, but works only in NT.

/// John
0
 

Author Comment

by:emiltor
ID: 1349905
Excelent !! I only use NT , Do you have any code or something ?
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349906
I guess this might work. You have to declare the function first!

Like this:

interface


  ...

  Function NetMessageBufferSend (
     pServername,
     pMsgName,
     pFromname: PWideChar;
     buf: pChar;
     buflen: DWORD): UINT; stdcall;
  external 'netapi32.dll' name 'NetMessageBufferSend';

implementation

{$R *.DFM}

procedure DoSendMessage(ServerName,Headline,From: String; Message: TStringList);
var
  i,count: Integer;
begin
  count:= 0;
  For i:= 0 to message.Count-1 do Inc(Count,length(message.strings[i])+1);
  If From='' then From:= #0; //uses the default loginName
  NetMessageBufferSend(PWideChar(ServerName),
                       PWideChar(Headline),
                       PWideChar(From),
                       Message.GetText,
                       count);
End;

..


end.


Does that work? ..I'm sorry, that I cannot test it myself, I haven't got two computers, but the app seemed to be busy doing something hehe. :-)

Cheers,
Williams
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1349907
Do you need further help, or is Williams comment enough?
The drawback with this method is: you can't handle the message yourself on the receiver end, unless you substitute the messenger service.

/// John

0
 

Author Comment

by:emiltor
ID: 1349908
I'm glad if you have any code John....

Williams have to explane his answer better - i don't understand it enought

thanks..... williams & John

(/Ho is better)
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1349909
If you go for Williams / johns answer, I think you should reject my answer...
0
 

Author Comment

by:emiltor
ID: 1349910
Sorry Blackman, when i go to the page you send me it doesn't work and now when i test again it works. and there is lots of stuff about my question ( "allright" )

Thanks...

0
 
LVL 4

Expert Comment

by:erajoj
ID: 1349911
Hi again,
Here's a simple unit with the functions supplied by Williams and some sample code:

unit NetMsg;

{ Example unit for sending messages over the network }
{ For users at experts-exchange, use freely at own risk }
{ created 1998-12-10 by John Johansson (erajoj) }

interface

uses Windows, Classes;

function NetMessageBufferSend(
   pServername,
   pMsgName,
   pFromname,
   pBuf: PWideChar;
   dwBufLen: DWORD): UINT; stdcall;
   external 'netapi32.dll' name 'NetMessageBufferSend';

{ Send strings to single recipient at optional server and with optional signature }
function DoSendMessage( pServerName, pFrom, pReceiver: PWideChar; rgsMsg: TStrings ): Boolean;
{ Send strings to multiple recipients at optional server and with optional signature }
function DoSendMessageEx( pServerName, pFrom: PWideChar; rgsReceiver, rgsMsg: TStrings ): Boolean;
{ Lightweight send strings to single recipient }
function SendMsg( sReceiver, sMessage: string ): Boolean;

implementation

function DoSendMessage( pServerName, pFrom, pReceiver: PWideChar; rgsMsg: TStrings ): Boolean;
var
  sMsg: WideString;
begin
  sMsg := rgsMsg.Text; { autoconvert from ansi to wide string }
  Result := NetMessageBufferSend(
    pServerName,
    pReceiver,
    pFrom,
    PWideChar( sMsg ),
    SizeOf( WideChar ) * ( Length( sMsg ) + 1 ) { 2 byte per char + zero terminator }
  ) = 0;
end;

function DoSendMessageEx( pServerName, pFrom: PWideChar; rgsReceiver, rgsMsg: TStrings ): Boolean;
var
  sMsg: WideString;
  iIndex: Integer;
begin
  Result := True;
  for iIndex := 0 to rgsReceiver.Count - 1 do
  begin
    sMsg   := rgsReceiver[ iIndex ]; { autoconvert from ansi to wide string }
    Result := Result and DoSendMessage( pServerName, pFrom, PWideChar( sMsg ), rgsMsg );
  end;
end;

function SendMsg( sReceiver, sMessage: string ): Boolean;
var
  sRec, sMsg: WideString;
begin
  sRec := sReceiver; { autoconvert from ansi to wide string }
  sMsg := sMessage;  { autoconvert from ansi to wide string }
  Result := NetMessageBufferSend(
    nil,
    PWideChar( sRec ),
    nil,
    PWideChar( sMsg ),
    SizeOf( WideChar ) * ( Length( sMsg ) + 1 ) { 2 byte per char + zero terminator }
  ) = 0;
end;

Samples:

uses ..., netmsg;
  ...

procedure TMainForm.Button1Click(Sender: TObject);
begin
  SendMsg( 'john', 'Hello! Let''s go out to lunch!' );
end;

procedure TMainForm.Button2Click(Sender: TObject);
begin
  DoSendMessageEx( '\\DEVSRV', nil, ColleagueListBox.Items, MessageListBox.Items );
end;

procedure TMainForm.Button3Click(Sender: TObject);
begin
  DoSendMessage( nil, nil, 'myonlyfriend', InfoStringList );
end;

procedure TMainForm.Button4Click(Sender: TObject);
begin
  if not SendMsg( 'emiltor', 'Enough?' ) then
    ShowMessage( 'Not good enough. Didn''t get through!' );
end;

end.

Can't really do any better than this right now...
Points go to Williams if this solution is sufficient.

/// John
0
 

Author Comment

by:emiltor
ID: 1349912
Thanks
Blackman,Williams,John,Raymond

Now i can send message

Keep the smile high..............
0
 
LVL 3

Expert Comment

by:williams2
ID: 1349913
You're welcome

Thanx to John for his corrections :-)

Regards,
Williams
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question