如题,代码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
IdSNMP;type
TForm1 = class(TForm)
msg: TIdSNMP;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
msg.Host := '127.0.0.1';
msg.Community := 'public';
msg.Query.Clear;
msg.Query.MIBAdd('1.3.6.1.2.1.2.2.1.16','');
msg.Query.PDUType := PDUGetRequest;
if msg.SendQuery then
begin
for i := 0 to msg.Reply.ValueCount - 1 do
begin
memo1.Lines.Add(msg.Reply.Value[i]);
end;
end
else
memo1.Lines.add('err');
end;end.请帮忙,看看,为什么不能成功。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
IdSNMP;type
TForm1 = class(TForm)
msg: TIdSNMP;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
msg.Host := '127.0.0.1';
msg.Community := 'public';
msg.Query.Clear;
msg.Query.MIBAdd('1.3.6.1.2.1.2.2.1.16','');
msg.Query.PDUType := PDUGetRequest;
if msg.SendQuery then
begin
for i := 0 to msg.Reply.ValueCount - 1 do
begin
memo1.Lines.Add(msg.Reply.Value[i]);
end;
end
else
memo1.Lines.add('err');
end;end.请帮忙,看看,为什么不能成功。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货