home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / unity / d23456 / SYNAPSE.ZIP / source / demo / snmp / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2001-02-03  |  1.3 KB  |  66 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   SNmPsend, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Edit1: TEdit;
  12.     Label1: TLabel;
  13.     Button1: TButton;
  14.     Label2: TLabel;
  15.     Label3: TLabel;
  16.     Edit2: TEdit;
  17.     Label4: TLabel;
  18.     Edit3: TEdit;
  19.     Memo1: TMemo;
  20.     Memo2: TMemo;
  21.     Label5: TLabel;
  22.     Label6: TLabel;
  23.     procedure Button1Click(Sender: TObject);
  24.   private
  25.     { Private declarations }
  26.   public
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36.  
  37. procedure TForm1.Button1Click(Sender: TObject);
  38. var
  39.   response,s:string;
  40.   n:integer;
  41. begin
  42.   if SNMPget(Edit3.Text,Edit2.Text,Edit1.Text,response)
  43.     then
  44.       begin
  45.         label2.Caption:='Success...';
  46.         memo1.Lines.Clear;
  47.         memo2.Lines.Clear;
  48.         memo1.Lines.Text:=response;
  49.         s:='';
  50.         for n:=1 to Length(response) do
  51.           begin
  52.             s:=s+'$'+IntToHex(Ord(response[n]),2)+' ';
  53.           end;
  54.         memo2.Lines.Text:=s;
  55.       end
  56.     else
  57.       begin
  58.         label2.Caption:='Not contacted... (Check SNMP host, community or MIB OID!)';
  59.         memo1.Lines.Clear;
  60.         memo2.Lines.Clear;
  61.       end;
  62. end;
  63.  
  64. end.
  65.  
  66.