Hello
Here's a quick sample I made for you, I didn't test it well, but it's cover the idea, it's contian class inhertied from TThread, and I used NetMessageBufferSend API to send the message
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
end;
type
TNetSend = class(TThread)
private
FUserName : string;
FMsg : string;
protected
constructor Create(UserName, Msg: string);
procedure Execute; override;
end;
type
NET_API_STATUS = DWORD;
function NetMessageBufferSend(Serve
Buf: PByte; Buflen: DWORD): NET_API_STATUS;stdcall;
var
Form1: TForm1;
implementation
{$R *.dfm}
function NetMessageBufferSend; external 'NetAPI32.dll' name 'NetMessageBufferSend';
procedure NetSend(const UserId, MessageText:string);
var
Return: NET_API_STATUS;
Recipient: array[0..64] of WideChar;
Buffer: array[0..500] of WideChar;
begin
StringToWideChar(UserId, @Recipient, SizeOf(Recipient));
StringToWideChar(MessageTe
Return := NetMessageBufferSend(nil, @Recipient, nil, @Buffer,
2 * Length(MessageText));
if not(Return = 0) then ShowMessage('Error');
end;
procedure TForm1.Button1Click(Sender
var
NS : TNetSend;
begin
NS := TNetSend.Create(Edit1.Text
Ns.Execute;
end;
constructor TNetSend.Create(UserName, Msg: string);
begin
inherited create(true);
FUserName := UserName;
FMsg := Msg;
end;
procedure TNetSend.Execute;
begin
inherited;
NetSend(FUserName, FMsg);
end;
end.
Best regards
Mohammed Nasman
Main Topics
Browse All Topics





by: emadatPosted on 2003-06-13 at 13:22:52ID: 8720558
Refer to this URL: http://www.midnightbeach.c om/jon/pub s/MsgWaits /MsgWaits. html
It is a great article -with downloadable suorce code- with which you can write your code in a function or a procedure; then pass it to the component which will run it in a thread for you.