Winbox Launcher

Ok…
I’ve created a “winbox launcher”… Very simple, manual, and stupid…
But now i can open many winbox with different address lists…

If anyone want try…
http://www.megaupload.com/?d=FM5K2UBP

The “address-lists” and winbox.exe path must go on winboxl.ini
ItemX must have 6 chars in name.
!!!NO CHECK IS DONE IN winboxl.ini FILE!!!

My winboxl.ini look like:

[WINBOX]
Path=c:\documents and settings\ajmacias\escritorio\winbox.exe

[CONFIGS]
Item0=winbox.cfg
Item1=winbo1.cfg
Item2=teste1.cfg

So i’ve 3 differents address-list :slight_smile:

Ah… the source.
It’s a stupid delphi 7 program coded very quickly…

unit Unit1;

{$IMAGEBASE $40000000}

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    ComboBox1: TComboBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    winbox_path: string;

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses uExecFromMem, inifiles, uWin;

procedure TForm1.Button1Click(Sender: TObject);
var
  hFile: THandle;
  bBuff:  array of byte;
  dSize:  DWORD;
  dRead:  DWORD;
  i: integer;
  j: integer;
begin
  hFile := CreateFile(Pchar(winbox_path), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
  if hFile <> INVALID_HANDLE_VALUE then
  begin
    dSize := GetFileSize(hFile, nil);
    SetLength(bBuff, dSize);
    ReadFile(hFile, bBuff[0], dSize, dRead, nil);
    CloseHandle(hFile);

    // search for "%s\winbox.cfg"
    for i:=0 to dSize - 20 do
    begin
      if (
            (bBuff[i+0]  = Ord('%')) and
            (bBuff[i+1]  = Ord('s')) and
            (bBuff[i+2]  = Ord('\')) and
            (bBuff[i+3]  = Ord('w')) and
            (bBuff[i+4]  = Ord('i')) and
            (bBuff[i+5]  = Ord('n')) and
            (bBuff[i+6]  = Ord('b')) and
            (bBuff[i+7]  = Ord('o')) and
            (bBuff[i+8]  = Ord('x')) and
            (bBuff[i+9]  = Ord('.')) and
            (bBuff[i+10] = Ord('c')) and
            (bBuff[i+11] = Ord('f')) and
            (bBuff[i+12] = Ord('g'))
      ) then
      begin
        for j:=0 to 5 do
        begin
          bBuff[i+3+j] := Ord(ComboBox1.text[1+j]);
        end;
      end;
    end;

    ExecuteFromMem(winbox_path, '', bBuff);
  end;
end;

procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
  key := #0;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  r: TIniFile;
  i: integer;
  itemname: string;
begin
  r := TIniFile.Create(Directorio_Aplicacion + 'winboxl.ini');
    winbox_path := r.ReadString('WINBOX', 'Path', 'c:\documents and settings\ajmacias\escritorio\winbox.exe');

    ComboBox1.Items.Clear;

    i := 0;
    repeat
      itemname := r.ReadString('CONFIGS', Format('Item%d',[i]), '-');
      if itemname <> '-' then
        ComboBox1.Items.Add(itemname);
      inc(i);
    until itemname = '-';

  r.Free;

end;

end.

I think is very easy to implement in mikrotik’s winbox.exe
But until mikrotik team find time to do…