各位!
想必大家都用过net send ,就是强行发送消息。
如果知道!最好给点代码!
谢了!
想必大家都用过net send ,就是强行发送消息。
如果知道!最好给点代码!
谢了!
解决方案 »
- 在新窗口的创建事件中写入的程度为何不执行(写在FormShow事件中也不执行)
- TServerSocket和TClientSocket做的C/S程序,网络断开,断电等的问题
- 怎么让ActiveX控件在IE中居中,自适应大小?
- 如何使一个窗口变成活动窗口呀?
- 结构体的问题
- sql问题!
- 关于ACCESS数据库的时间查询问题
- 一个很菜的问题,和var有关
- 在对table执行insertrecord时提示 'index is read only'怎么办,一定要拉一把.我是新手.
- 请教大侠:为什么用TABLE.LOCATE来定位会出现该记录后面的记录不能显示?怎样避免?
- 怎样让DBGrid暂时不随数据源刷新?
- 补问:有关pagecontrol的changing事件问题?用(sender as TPageControl).ActivePage.Name返回上一页的名字?
给分呀:)
unit MainUnit;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;type
TMainForm = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
StatusLabel: TPanel;
Panel4: TPanel;
Label1: TLabel;
AdrComboBox: TComboBox;
Panel5: TPanel;
MsgText: TMemo;
SendBitBtn: TBitBtn;
AboutBitBtn: TBitBtn;
ExitBitBtn: TBitBtn;
procedure SendBitBtnClick(Sender: TObject);
private
{ Private declarations }
public
function SendMsg(Toh, From, Msg: string): Integer;
{ Public declarations }
end;
function NetMessageBufferSend(Servername, MsgName, FromName, Buf: PWideChar;
var BufLen: Integer): Integer;stdcall;var
MainForm: TMainForm;implementation{$R *.dfm}function NetMessageBufferSend; external 'netapi32.dll' name 'NetMessageBufferSend';function TMainForm.SendMsg(Toh,From,Msg: string): integer;
var
ToName: array [0..64] of WideChar;
FromName: array [0..64] of WideChar;
WMsgText: array [0..1000] of WideChar;
MsgLen, i: Integer;
begin
for i := 0 to 64 do
begin
ToName[i] :=#0;
FromName[i] := #0;
end;
StringToWideChar(Toh, ToName, MsgLen);
StringToWideChar(From, FromName, MsgLen);
for i := 0 to 1000 do WMsgText[i] := #0;
StringToWideChar(Msg, WMsgText, MsgLen);
Result := NetMessageBufferSend(nil, ToName, nil, WMsgText, MsgLen);
end;procedure TMainForm.SendBitBtnClick(Sender: TObject);
var
res : integer;
begin
if AdrComboBox.Text <> '' then
begin
StatusLabel.Caption := 'Wait...';
Update;
if AdrComboBox.Items.IndexOf(AdrComboBox.Text) = -1 then
begin
if AdrComboBox.Items.Count > 20 then
AdrComboBox.Items.Delete(0);
AdrComboBox.Items.Add(AdrComboBox.Text);
end;
res := SendMsg(AdrComboBox.Text, '', MsgText.Text);
case res of
0 : StatusLabel.Caption := 'The message is sent';
87 : StatusLabel.Caption := 'The parameter is incorrect';
123 : StatusLabel.Caption := 'sintax is incorrect';
2273 : StatusLabel.Caption := 'Can not find'+ AdrComboBox.Text;
else
StatusLabel.Caption := 'Error: '+IntToStr(res);
end;
end;
end;end.