作者在 interface下use中定义了NMDUP。部分代码如下,大虾指教
NMUDP_Chat.ReportLevel := status_Basic;
NMUDP_Chat.RemoteHost := HostName;
NMUDP_Chat.RemotePort := HostPort;
NMUDP_Chat.LocalPort := HostPort;
function TForm1.Emote:Boolean; //face
var
SourceStr:string; //sources string
DestStr:string; //destination string
EmoteS:TStringList; //Use a stringlist object to store and manipulate a list of strings
ReceiverName:String;
CChat:array[1..255]of Char;
tmpStr,eStr,mStr,moteStr:String;
I,tmpi:Integer;
begin
Result:=false;
SourceStr:=Edit3.Text+'';
DestStr:=Copy(Sourcestr,1,2)
if DestStr='/e' then
begin
EmoteS:=TStringList.Create;
try
with TInifile.Create(GetExePath+'Emotes.emt') do //GetExePath: public function
begin
ReadSection('Emote',EmoteS);
RichEdit1.Lines.Add(#13);
RichEdit1.Lines.Add('显示表情符号(//<表情符号>[<空格>附加语句]):');
RichEdit1.Lines.Append(EmoteS.CommaText);
//CommaText to get or set all the strings in the TStrings object in a single comma-delimited string.
RichEdit1.Lines.Add(#13);
Edit3.Text:=#0;
end;
finally
EmoteS.Free;
end;
Result:=True;
end;
if DestStr='//' then
begin
tmpStr:=Pos('',SourceStr);
eStr:=Copy(SourceStr,3,tmpi-3);
mStr:=Copy(SourceStr,tmpi+1,Length(SourceStr)-tmpi-1);
ReceiverName:=Edit2.Text;
with TInifile.Create(GetExePath+'Emotes.emt') do
begin
if ReceiverName<>'' then
begin
tmpStr:=ReadString('Emotes',eStr,'');
moteStr:=FastReplace(tmpStr,'<Receiver>',ReceiverName,false);
end else
begin
moteStr:=ReadString('Emote',eStr,'');
end;
if moteStr<>'' then
begin
tmpStr:='1'+LuckName+moteStr+''+mStr;
for i:=1 to Length(tmpStr) do
CChat:=tmpStr;
NMUDP_Chat.SendBuffer(CChat,Length(TmpStr));
end else
begin
RichEdit1.Lines.Add('对不起,表情符号//'+eStr+'看不懂!');
Edit3.Clear;
end;
Result:=true;
end;
end;
end;