Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 2.50 average. Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2004, 02:38 AM
jrahma jrahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 40 jrahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 11 sec
Reputation Power: 9
Broadcast network message

How can I send a message from the administrator to all (or some) users in the network using Delphi?

Reply With Quote
  #2  
Old October 30th, 2004, 08:21 AM
SilverDB's Avatar
SilverDB SilverDB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Romania
Posts: 173 SilverDB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 45 m 53 sec
Reputation Power: 9
Send a message via Yahoo to SilverDB
Lightbulb

**************************
Here's an example - Hope it helps
**************************

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function NetSend(dest, Source, Msg: string): Longint; overload;
type
TNetMessageBufferSendFunction = function(servername, msgname, fromname: PWideChar;
buf: PWideChar; buflen: Cardinal): Longint;
stdcall;
var
NetMessageBufferSend: TNetMessageBufferSendFunction;
SourceWideChar: PWideChar;
DestWideChar: PWideChar;
MessagetextWideChar: PWideChar;
Handle: THandle;
begin
Handle := LoadLibrary('NETAPI32.DLL');
if Handle = 0 then
begin
Result := GetLastError;
Exit;
end;
@NetMessageBufferSend := GetProcAddress(Handle, 'NetMessageBufferSend');
if @NetMessageBufferSend = nil then
begin
Result := GetLastError;
Exit;
end;

MessagetextWideChar := nil;
SourceWideChar := nil;
DestWideChar := nil;

try
GetMem(MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1);
GetMem(DestWideChar, 20 * SizeOf(WideChar) + 1);
StringToWideChar(Msg, MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1);
StringToWideChar(Dest, DestWideChar, 20 * SizeOf(WideChar) + 1);

if Source = '' then
Result := NetMessageBufferSend(nil, DestWideChar, nil,
MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1)
else
begin
GetMem(SourceWideChar, 20 * SizeOf(WideChar) + 1);
StringToWideChar(Source, SourceWideChar, 20 * SizeOf(WideChar) + 1);
Result := NetMessageBufferSend(nil, DestWideChar, SourceWideChar,
MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1);
FreeMem(SourceWideChar);
end;
finally
FreeMem(MessagetextWideChar);
FreeLibrary(Handle);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
NetSend('Silver','Silver','Yoooooooo');
end;

end.

Reply With Quote
  #3  
Old November 16th, 2004, 02:13 AM
jrahma jrahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 40 jrahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 11 sec
Reputation Power: 9
Hi,

I tried you code by just changing the dest and source but I am not getting any messages sent..

Here is my code:

NetSend('rahma-j','rahma-j','Yoooooooo');


Best Regards,
Jassim Rahma

Reply With Quote
  #4  
Old November 16th, 2004, 10:53 AM
SilverDB's Avatar
SilverDB SilverDB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Romania
Posts: 173 SilverDB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 45 m 53 sec
Reputation Power: 9
Send a message via Yahoo to SilverDB
This only works on windows nt platforms and it's a replacement of the command line "net send IP/computer_name message", it does not work on Win 95, 98, ME.
If you are interested in a chat there are a couple of freeware products out there that can do the job.

Reply With Quote
  #5  
Old November 17th, 2004, 01:39 AM
jrahma jrahma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 40 jrahma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 11 sec
Reputation Power: 9
thanks,


i don't want chat application.


I am using Windows XP

Reply With Quote
  #6  
Old February 9th, 2005, 01:33 AM
SilverDB's Avatar
SilverDB SilverDB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Romania
Posts: 173 SilverDB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 45 m 53 sec
Reputation Power: 9
Send a message via Yahoo to SilverDB
There is a service in Win Xp named "Messenger" that deals with the "net send" ... make sure it is started.

Reply With Quote
  #7  
Old November 21st, 2012, 04:54 PM
Apponobjeme Apponobjeme is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Location: Yugoslavia
Posts: 3 Apponobjeme User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 23 sec
Reputation Power: 0
Send a message via ICQ to Apponobjeme
hello

hello

Reply With Quote
  #8  
Old November 24th, 2012, 10:53 AM
Ambuttruigree Ambuttruigree is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Location: Andorra
Posts: 5 Ambuttruigree User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 10 sec
Reputation Power: 0
Send a message via ICQ to Ambuttruigree
hello

hello

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Broadcast network message

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap