Browse Source

Initial version ignored (2005-08-13 for BICA McAfee)

This is the second version. The main change is automatic computation of the autorun.inf path (!)
Frederic G. Marand 16 years ago
commit
fc79e2bd34
4 changed files with 148 additions and 0 deletions
  1. 16 0
      OSInetAutoRunner.dpr
  2. BIN
      OSInetAutoRunner.res
  3. 35 0
      ufmMain.dfm
  4. 97 0
      ufmMain.pas

+ 16 - 0
OSInetAutoRunner.dpr

@@ -0,0 +1,16 @@
+program OSInetAutoRunner;
+{
+$Id: OSInetAutoRunner.dpr,v 1.1 2007-10-08 19:59:13 marand Exp $
+}
+
+uses
+  Forms,
+  ufmMain in 'ufmMain.pas' {fmOAR};
+
+{$R *.res}
+
+begin
+  Application.Initialize;
+  Application.CreateForm(TfmOAR, fmOAR);
+  Application.Run;
+end.

BIN
OSInetAutoRunner.res


+ 35 - 0
ufmMain.dfm

@@ -0,0 +1,35 @@
+object fmOAR: TfmOAR
+  Left = 266
+  Top = 198
+  Width = 696
+  Height = 395
+  Caption = 'OSInet AutoRunner'
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'MS Sans Serif'
+  Font.Style = []
+  OldCreateOrder = False
+  OnCreate = FormCreate
+  PixelsPerInch = 96
+  TextHeight = 13
+  object M: TMemo
+    Left = 0
+    Top = 0
+    Width = 688
+    Height = 368
+    Align = alClient
+    Enabled = False
+    Lines.Strings = (
+      'M')
+    TabOrder = 0
+  end
+  object tm: TTimer
+    Enabled = False
+    Interval = 5000
+    OnTimer = tmTimer
+    Left = 600
+    Top = 16
+  end
+end

+ 97 - 0
ufmMain.pas

@@ -0,0 +1,97 @@
+{$J+}
+{
+OSInet media autorunner
+Copyright 2005 Ouest Systèmes Informatiques
+
+2005-08-13 Initial version created for a McAfee CD for BICA
+2007-10-08 Updated for a Zend DVD for ACSSA
+
+$Id: ufmMain.pas,v 1.1 2007-10-08 19:59:13 marand Exp $
+}
+unit ufmMain;
+
+interface
+
+uses
+  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+  Dialogs, StdCtrls, ExtCtrls, IniFiles, ShellAPI;
+
+type
+  TfmOAR = class(TForm)
+    M: TMemo;
+    tm: TTimer;
+    procedure FormCreate(Sender: TObject);
+    procedure tmTimer(Sender: TObject);
+  private
+    { Déclarations privées }
+    procedure ApplicationActivate (Sender : TObject) ;
+  public
+    { Déclarations publiques }
+  end;
+
+var
+  fmOAR: TfmOAR;
+
+implementation
+
+{$R *.dfm}
+
+procedure TfmOAR.ApplicationActivate (Sender : TObject) ;
+
+  const
+      csIniFile = 'autorun.inf' ;
+      csSection = 'autorun' ;
+      csVerb    = 'index' ;
+
+      isLoaded  : Boolean = False ;
+
+  var ini : TIniFile ;
+      sl  : TStringList ;
+      cmd : String ;
+      ret : Cardinal ;
+      msg : String ;
+
+  begin
+  if isLoaded then
+    exit ;
+
+  isLoaded := True ;
+  ini := TIniFile.Create(GetCurrentDir + '\' + csIniFile) ;
+  sl  := TStringList.Create ;
+  ini.ReadSectionValues(csSection, sl);
+//  ShowMessage('il y a ' + IntToStr(sl.count) + ' chaines');
+  cmd := sl.Values [csVerb] ;
+  if cmd = '' then
+    ShowMessage ('Pas de clause ' + csVerb + ' dans la section '
+      + csSection + ' de ' + csIniFile + '. Rien à charger.')
+  else
+    begin
+    msg := 'Chargement de: ' + cmd ;
+    ret := ShellExecute (Application.Handle, 'open', PAnsiChar (cmd), nil, nil, SW_SHOWMAXIMIZED) ;
+    if ret < 32 then
+      begin
+      msg := msg +  ('--> Erreur ' + InttoStr (ret)) ;
+      tm.Interval := 10000 ;
+      end
+    else
+      msg := msg +  ('--> OK') ;
+      tm.Interval := 1000 ;
+    fmOAR.Visible := True ;
+    Application.BringToFront ;
+    Application.ProcessMessages ;
+    M.Text := msg ;
+    tm.Enabled := True ;
+    end ;
+  end;
+
+procedure TfmOAR.FormCreate(Sender: TObject);
+  begin
+  Application.OnActivate := ApplicationActivate ;
+  end;
+
+procedure TfmOAR.tmTimer(Sender: TObject);
+  begin
+  Application.Terminate ;
+  end;
+
+end.