关于信使服务 (50分)

  • 主题发起人 主题发起人 muyexin
  • 开始时间 开始时间
M

muyexin

Unregistered / Unconfirmed
GUEST, unregistred user!
今天有兴趣做个信使的小程序。(Windows 2000/XP/NT)<br>麻烦是:NetMessageBufferSend 函数中,FromName 参数项形同虚设,只能是 FromName 等于本机名时,才发送成功。而 FromName 为 Nil &nbsp;时,在别人电脑上弹出的信使服务上,显示的还是本机名。为别的值则不能发信息。<br><br>请问谁做过这个玩艺,请指教。要别人显示发消息的人不是真实的本机名。
 
网上有种批量发送广告的信史程序。你可以找下看看~<br>那个软件是不显示发送方的
 
不会吧,<br>我以前试过的啊,fromname可以随意设置的啊,别人机子上显示的是你随意设置的名字啊
 
来如风:<br>可否给段代码看一下呀,为什么我这儿不行,可能哪方面出问题了<br>
 
我的网站上有jetAD这个软件,发送短信特别好用,呵呵,估计我这个是国内最高使用messenger服务的程序了,当然,是外国公司的,不是我编的,支持批量发送
 
任远:<br><br>有没有源码呀?
 
var msgname,fromname:PWideChar;<br>&nbsp; &nbsp; msglen:Cardinal;<br>&nbsp; &nbsp; buf:PWideChar;<br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp; msgname:=PWideChar(WideString(pcusred.Text)) ;<br>&nbsp; &nbsp; &nbsp; &nbsp; fromname:=PWideChar(WideString(usred.Text)) ;<br>&nbsp; &nbsp; &nbsp; &nbsp; msglen:=2*Length(msgmem.Lines.Text) ;<br>&nbsp; &nbsp; &nbsp; &nbsp; buf:=PWideChar(WideString(msgmem.Lines.Text)) ;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; LmMsg.LoadLmMsg ;<br>&nbsp; &nbsp; &nbsp; &nbsp; LmMsg.NetMessageBufferSend(nil,msgname,fromname,buf,msglen) ;<br>&nbsp; &nbsp; &nbsp; &nbsp; LmMsg.UnloadLmMsg ;<br>end;<br>
 
还是不行啊,代码我看了,和上面的也没有什么两样~<br>怎么会这样呢,
 
你看看这个,我这边总是出异常,能达到你的目的。或许你看看就好:<br><br>function NetMessageBufferSend(AServerName: PWideChar;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AMsgName: PWideChar;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AFromName: PWideChar;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Buf: PWideChar;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BufLen: DWORD): Integer; cdecl;<br><br><br>var<br>&nbsp; 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>&nbsp; awcToName, awcFromName, awcMesgBuffer: WideString;<br>&nbsp; len : Integer;<br>begin<br>&nbsp; Result := 0;<br>&nbsp; If (Length(ATarget) = 0) or (Length(AText) = 0) Then<br>&nbsp; &nbsp; Exit;<br><br>&nbsp; try<br>&nbsp; &nbsp; awcToName := ATarget +'*';<br>&nbsp; &nbsp; If Length(AFrom) &gt; 0 Then Begin<br>&nbsp; &nbsp; &nbsp; awcFromname := AFrom;<br>&nbsp; &nbsp; End;<br>&nbsp; &nbsp; awcMesgBuffer := AText;<br>&nbsp; &nbsp; len := Length( AText )+1;<br>&nbsp; &nbsp; Result := NetMessageBufferSend(Nil,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @awcToName[1],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @awcFromName[1],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @awcMesgBuffer[1],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; len * sizeof(WideChar)+2 );<br>&nbsp; except<br>&nbsp; end;<br>End;<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; SendNetMessage(edTo.Text, edMsg.Text, edFrom.Text);<br>end;<br><br>
 
谢谢大家的回复。不过我试了之后还是不行。核心代码这方面,我觉得没什么问题了吧。不管是怎么样,都是:输入的 FromName 为本机名时,就发送成功,否则发送不成功。<br><br>难道是 我的电脑的问题? 我装的是 2000+ sp4 。
 
果然是微软的问题, ****,在没有装 Service Pack 的电脑上试,就没问题。<br>有SP3、SP4 的,都不可以。<br><br>散分。
 
多人接受答案了。
 
后退
顶部