Solved

Net send in delphi

Posted on 2003-11-21
8
1,502 Views
Last Modified: 2012-06-27
Hi experts,

I was wondering how I can use a net send in my program. Not a net send through DOS (shellexecute) but one actually using the net DLL. Thanks.
0
Comment
Question by:ionet
8 Comments
 
LVL 6

Accepted Solution

by:
GloomyFriar earned 32 total points
ID: 9796456
As far as I remember it can be done with using of mailslot.
0
 

Assisted Solution

by:amjedmsa
amjedmsa earned 31 total points
ID: 9797035
it seem you dont want to show your app user the dos screen thats simple and also i dont know any free compnent or comercial compnent to do this trik

check this code put it under a button e.g
_____________________________________________________
procedure TForm1.Button1Click(Sender: TObject);
begin


shellexecute(handle,'open',pchar('net'),pchar(' '+'send' +' '+ edit1.text + ' ' + edit2.text),nil,SW_HIDE)

end;
____________________________________________________

and edit1 will be the host name or the ip number of the computer
edit2 will be the message

once u hit the button the message will apear instantly in his computer
and no one will see the command line screen
also this is better than a component this way save's space
0
 

Expert Comment

by:amjedmsa
ID: 9797050
oops forgot to tell dont forget to put shellapi in the uses
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Assisted Solution

by:cqhall
cqhall earned 31 total points
ID: 9799166
Try This:

function NetSend(dest, source, msg: string): longint;
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;
 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
 begin
  result := NetMessageBufferSend(nil, DestWideChar, nil, MessagetextWideChar, Length(msg) * SizeOf(WideChar) + 1)
 end 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;
0
 

Author Comment

by:ionet
ID: 9802831
care to do some explaining instead of just code?
0
 
LVL 4

Assisted Solution

by:Delphian
Delphian earned 31 total points
ID: 10173431
Simple:

cqhall - (S)/He uses the API contained on NETAPI.dll on what
the NET SEND is based. It calls the DLL, gets the function
and configure the parameters to finally execute the send.
After it, it unloads the DLL and free all memory.

amjedmsa - S/He uses the shell ShellExecute function available
on shellapi.pas unit on Delphi. It runs the NET.exe executable
like you would make it manually.

If  you accept this answer, please split the points....

[]s Fabricio

 
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
Virtuailstring tree compare node issue 14 103
HTML text in the body of an email (delphi code) 12 94
When i run adoquery my application freezes 26 150
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

939 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now