你看看这个,我这边总是出异常,能达到你的目的。或许你看看就好:<br><br>function NetMessageBufferSend(AServerName: PWideChar;<br> AMsgName: PWideChar;<br> AFromName: PWideChar;<br> Buf: PWideChar;<br> BufLen: DWORD): Integer; cdecl;<br><br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>function NetMessageBufferSend; external 'netapi32.dll' name 'NetMessageBufferSend';<br><br>Function SendNetMessage(const ATarget, AText, AFrom: string): Integer;<br>var<br> awcToName, awcFromName, awcMesgBuffer: WideString;<br> len : Integer;<br>begin<br> Result := 0;<br> If (Length(ATarget) = 0) or (Length(AText) = 0) Then<br> Exit;<br><br> try<br> awcToName := ATarget +'*';<br> If Length(AFrom) > 0 Then Begin<br> awcFromname := AFrom;<br> End;<br> awcMesgBuffer := AText;<br> len := Length( AText )+1;<br> Result := NetMessageBufferSend(Nil,<br> @awcToName[1],<br> @awcFromName[1],<br> @awcMesgBuffer[1],<br> len * sizeof(WideChar)+2 );<br> except<br> end;<br>End;<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> SendNetMessage(edTo.Text, edMsg.Text, edFrom.Text);<br>end;<br><br>