如何使用Windows2000内置信使服务(100分)

  • 主题发起人 主题发起人 有故事的人
  • 开始时间 开始时间

有故事的人

Unregistered / Unconfirmed
GUEST, unregistred user!
如何使用Windows2000内置信使服务在局域网内发送和接入系统信息!
急啊
 
net send computer message
 
还没有其它方法,要用API的,最好也能接受。
 
我有delphi源程序
 
楼上的,有就贴出来,说这个话钓人胃口干吗?

代码我也有(发消息,收没有),你有就快贴出来,我不想和你争这100分!
 
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;

function NetSend(Dest, Msg: string): Longint; overload;

begin

Result := NetSend(Dest, '', Msg);

end;

function NetSend(Msg: string): Longint; overload;

begin

Result := NetSend('', '', Msg);

end;
 
我也是从别人那里学来的,方法和楼上的不一样:

procedure SendNetMessage(YourName, ComputerName, MessageStr: String);
{=================================================================
功 能 : 向指定的机器发送桌面消息。
参 数 : 显示给用户的名称,指定机器的名称,发送的消息。
作者: Highpeak
版 本 : 1.0 2003/9/3/ 10:00
其他说明:通过创建邮件槽的方式向其他机器发送桌面消息。
=================================================================}

Var
Rc: LongBool;
MsHandle: Longint;
MsgText: String;
BytesWritten: Cardinal;
MailSlotName: String;
begin
MailSlotName := '//' + ComputerName + '/mailslot/messngr';
MsgText := YourName + Chr(0) + ComputerName + Chr(0) + MessageStr +
Chr(0);
MsHandle := CreateFile(PChar(MailSlotName), GENERIC_WRITE,
FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, $FFFFFFFF);
if MsHandle = INVALID_HANDLE_VALUE then
RaiseLastWin32Error;

RC := WriteFile(MsHandle, Pointer(MsgText)^, Length(MsgText),
BytesWritten, 0);

if not Rc then
RaiseLastWin32Error;

Rc := CloseHandle(MsHandle);

end;
 
后退
顶部