📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
IdSNMP,IdStack,IdASN1Util; //,IdSNMP
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
SNMP: TIdSNMP;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
// snmp:Tidsnmp;
end;
var
Form1: TForm1;
error,Reply:string;
result:boolean;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if SNMP = Nil then SNMP := TIdSNMP.Create(nil);
SNMP.Community := 'public';
SNMP.Host :='192.168.2.100';
SNMP.Query.Clear;
SNMP.Query.PDUType := PDUGetRequest;
SNMP.Query.MIBAdd(edit1.Text, '',ASN1_INT);
snmp.Active := True;
if not SNMP.SendQuery then
begin
Error := 'Error al consultar OID(' + IntToStr(SNMP.Query.ErrorStatus) ;
memo1.Lines.Add(Error);
// Reply := SNMP.Reply.Value[0];
// memo1.Lines.Add(Trim(SNMP.Reply.MIBOID.Text) + ': ' + Trim(SNMP.Reply.MIBValue.Text));
end
else
begin
Reply := SNMP.Reply.Value[0];
memo1.Lines.Add(Trim(SNMP.Reply.MIBOID.Text) + ': ' + Trim(SNMP.Reply.MIBValue.Text));
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -