//-----------------------------------------------------------------------//
//#######################################################################//
//## Function NetSend: ##//
//#######################################################################//
//## Datum: Änderung: ##//
//## ====== ========= ##//
//## 10.07.2001 Initial Release ##//
//#######################################################################//
{$HINTS OFF}
function NetSend(Dest, Source, Msg:
string): Longint;
overload;
type
TNetMessageBufferSendFunction =
function(Servername, Mmsgname, 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
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;
{$HINTS ON}
//-----------------------------------------------------------------------//
//#######################################################################//
//## Function NetSend: ##//
//#######################################################################//
//## Datum: Änderung: ##//
//## ====== ========= ##//
//## 10.07.2001 Initial Release ##//
//#######################################################################//
function NetSend(Dest, Msg:
string): Longint;
overload;
begin
Result := NetSend(Dest, '
', Msg);
end;
//-----------------------------------------------------------------------//
//#######################################################################//
//## Function NetSend: ##//
//#######################################################################//
//## Datum: Änderung: ##//
//## ====== ========= ##//
//## 10.07.2001 Initial Release ##//
//#######################################################################//
function NetSend(Msg:
string): Longint;
overload;
begin
Result := NetSend('
', '
', Msg);
end;