Subversion Repositories userdetect2

Rev

Rev 85 | Rev 87 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. unit UD2_Main;
  2.  
  3. interface
  4.  
  5. {$IF CompilerVersion >= 25.0}
  6. {$LEGACYIFEND ON}
  7. {$IFEND}
  8.  
  9. {$INCLUDE 'UserDetect2.inc'}
  10.  
  11. uses
  12.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  13.   Dialogs, StdCtrls, Grids, ValEdit, UD2_Obj, ComCtrls, ImgList, ExtCtrls,
  14.   CommCtrl, Menus, VTSListView, VTSCompat;
  15.  
  16. const
  17.   DefaultIniFile = 'UserDetect2.ini';
  18.   DefaultWarnIfNothingMatches = 'false';
  19.   TagWarnIfNothingMatches = 'WarnIfNothingMatches';
  20.   DefaultCloseAfterLaunching = 'false';
  21.   TagCloseAfterLaunching = 'CloseAfterLaunching';
  22.   TagIcon = 'Icon';
  23.  
  24. type
  25.   TUD2MainForm = class(TForm)
  26.     OpenDialog1: TOpenDialog;
  27.     PageControl1: TPageControl;
  28.     TasksTabSheet: TTabSheet;
  29.     TabSheet2: TTabSheet;
  30.     TabSheet3: TTabSheet;
  31.     IniTemplateMemo: TMemo;
  32.     TabSheet4: TTabSheet;
  33.     TasksListView: TVTSListView;
  34.     TasksImageList: TImageList;
  35.     SaveDialog1: TSaveDialog;
  36.     TabSheet5: TTabSheet;
  37.     Image1: TImage;
  38.     Label1: TLabel;
  39.     Label2: TLabel;
  40.     Label3: TLabel;
  41.     Label4: TLabel;
  42.     Label5: TLabel;
  43.     Label6: TLabel;
  44.     Label7: TLabel;
  45.     Label8: TLabel;
  46.     LoadedPluginsListView: TVTSListView;
  47.     IdentificationsListView: TVTSListView;
  48.     ErrorsTabSheet: TTabSheet;
  49.     ErrorsMemo: TMemo;
  50.     Memo1: TMemo;
  51.     Panel1: TPanel;
  52.     OpenTDFButton: TButton;
  53.     SaveTDFButton: TButton;
  54.     TasksPopupMenu: TPopupMenu;
  55.     Run1: TMenuItem;
  56.     Properties1: TMenuItem;
  57.     IdentificationsPopupMenu: TPopupMenu;
  58.     CopyTaskDefinitionExample1: TMenuItem;
  59.     Button3: TButton;
  60.     VersionLabel: TLabel;
  61.     LoadedPluginsPopupMenu: TPopupMenu;
  62.     MenuItem1: TMenuItem;
  63.     Panel2: TPanel;
  64.     Image2: TImage;
  65.     DynamicTestGroupbox: TGroupBox;
  66.     DynamicTestPluginComboBox: TComboBox;
  67.     DynamicTestPluginLabel: TLabel;
  68.     DynamicTestDataLabel: TLabel;
  69.     DynamicTestDataEdit: TEdit;
  70.     DynamicTestButton: TButton;
  71.     procedure FormDestroy(Sender: TObject);
  72.     procedure TasksListViewDblClick(Sender: TObject);
  73.     procedure TasksListViewKeyPress(Sender: TObject; var Key: Char);
  74.     procedure OpenTDFButtonClick(Sender: TObject);
  75.     procedure SaveTDFButtonClick(Sender: TObject);
  76.     procedure URLLabelClick(Sender: TObject);
  77.     procedure TasksPopupMenuPopup(Sender: TObject);
  78.     procedure Run1Click(Sender: TObject);
  79.     procedure Properties1Click(Sender: TObject);
  80.     procedure IdentificationsPopupMenuPopup(Sender: TObject);
  81.     procedure CopyTaskDefinitionExample1Click(Sender: TObject);
  82.     procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
  83.     procedure Button3Click(Sender: TObject);
  84.     procedure LoadedPluginsPopupMenuPopup(Sender: TObject);
  85.     procedure MenuItem1Click(Sender: TObject);
  86.     procedure FormCreate(Sender: TObject);
  87.     procedure DynamicTestButtonClick(Sender: TObject);
  88.   protected
  89.     ud2: TUD2;
  90.     procedure LoadTaskList;
  91.     procedure LoadDetectedIDs;
  92.     procedure LoadINITemplate;
  93.     procedure LoadLoadedPluginList;
  94.     procedure LoadDynamicPluginList;
  95.     function GetIniFileName: string;
  96.     procedure DoRun(ShortTaskName: string);
  97.     procedure CheckForErrors;
  98.   public
  99.     procedure Run;
  100.   end;
  101.  
  102. var
  103.   UD2MainForm: TUD2MainForm;
  104.  
  105. implementation
  106.  
  107. {$R *.dfm}
  108.  
  109. uses
  110.   ShellAPI, Clipbrd, Math, AlphaNumSort, UD2_Utils, UD2_TaskProperties, UD2_Parsing;
  111.  
  112. type
  113.   TUD2ListViewEntry = class(TObject)
  114.     ShortTaskName: string;
  115.     CloseAfterLaunching: boolean;
  116.     TaskPropertiesForm: TForm;
  117.   end;
  118.  
  119. function AddIconRecToImageList(rec: TIconFileIdx; ImageList: TImageList): integer;
  120. var
  121.   icon: TIcon;
  122. begin
  123.   icon := TIcon.Create;
  124.   try
  125.     icon.Handle := ExtractIcon(Application.Handle, PChar(rec.FileName), rec.IconIndex);
  126.  
  127.     // result := ImageList.AddIcon(ico);
  128.     result := AddTransparentIconToImageList(ImageList, icon);
  129.   finally
  130.     icon.Free;
  131.   end;
  132. end;
  133.  
  134. { TUD2MainForm }
  135.  
  136. function TUD2MainForm.GetIniFileName: string;
  137. resourcestring
  138.   LNG_FILE_NOT_FOUND = 'File "%s" not found.';
  139. begin
  140.   if (ParamCount >= 1) and not CheckBoolParam(1, 'C') then
  141.   begin
  142.     if FileExists(ParamStr(1)) then
  143.     begin
  144.       result := ParamStr(1);
  145.     end
  146.     else
  147.     begin
  148.       ExitCode := EXITCODE_INI_NOT_FOUND;
  149.       MessageDlg(Format(LNG_FILE_NOT_FOUND, [ParamStr(1)]), mtError, [mbOK], 0);
  150.       result := '';
  151.     end;
  152.     Exit;
  153.   end
  154.   else
  155.   begin
  156.     if FileExists(DefaultIniFile) then
  157.     begin
  158.       result := DefaultIniFile;
  159.       Exit;
  160.     end;
  161.  
  162.     if FileExists(GetOwnCmdName + '.ini') then
  163.     begin
  164.       result := GetOwnCmdName + '.ini';
  165.       Exit;
  166.     end;
  167.  
  168.     if CompatOpenDialogExecute(OpenDialog1) then
  169.     begin
  170.       result := OpenDialog1.FileName;
  171.       Exit;
  172.     end;
  173.  
  174.     result := '';
  175.     Exit;
  176.   end;
  177. end;
  178.  
  179. procedure TUD2MainForm.LoadTaskList;
  180. var
  181.   sl: TStringList;
  182.   i: integer;
  183.   ShortTaskName, iconString: string;
  184.   iconIndex: integer;
  185.   obj: TUD2ListViewEntry;
  186. begin
  187.   TasksListView.Clear;
  188.   sl := TStringList.Create;
  189.   try
  190.     ud2.GetTaskListing(sl);
  191.     for i := 0 to sl.Count-1 do
  192.     begin
  193.       ShortTaskName := sl.Names[i];
  194.  
  195.       Obj := TUD2ListViewEntry.Create;
  196.       Obj.ShortTaskName := ShortTaskName;
  197.       Obj.CloseAfterLaunching := ud2.ReadMetatagBool(ShortTaskName, TagCloseAfterLaunching, DefaultCloseAfterLaunching);
  198.  
  199.       TasksListView.AddItem(sl.Values[ShortTaskName], TObject(Obj));
  200.  
  201.       iconString := ud2.ReadMetatagString(ShortTaskName, TagIcon, '');
  202.       if iconString <> '' then
  203.       begin
  204.         iconIndex := AddIconRecToImageList(SplitIconString(iconString), TasksImageList);
  205.         if iconIndex <> -1 then
  206.         begin
  207.           TasksListView.Items.Item[TasksListView.Items.Count-1].ImageIndex := iconIndex;
  208.         end;
  209.       end;
  210.     end;
  211.   finally
  212.     sl.Free;
  213.   end;
  214. end;
  215.  
  216. procedure TUD2MainForm.DoRun(ShortTaskName: string);
  217. resourcestring
  218.   LNG_TASK_NOT_EXISTS = 'The task "%s" does not exist in the INI file.';
  219.   LNG_NOTHING_MATCHES = 'No identification string matches to your environment. No application was launched. Please check the Task Definition File.';
  220. var
  221.   i: integer;
  222.   cmds: TUD2CommandArray;
  223. begin
  224.   if not ud2.TaskExists(ShortTaskName) then
  225.   begin
  226.     // This can happen if the task name is taken from command line
  227.     MessageDlg(Format(LNG_TASK_NOT_EXISTS, [ShortTaskName]), mtError, [mbOK], 0);
  228.     ExitCode := EXITCODE_TASK_NOT_EXISTS;
  229.     Exit;
  230.   end;
  231.  
  232.   SetLength(cmds, 0);
  233.   cmds := ud2.GetCommandList(ShortTaskName);
  234.  
  235.   if (Length(cmds) = 0) and ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatches, DefaultWarnIfNothingMatches) then
  236.   begin
  237.     MessageDlg(LNG_NOTHING_MATCHES, mtWarning, [mbOK], 0);
  238.     ExitCode := EXITCODE_TASK_NOTHING_MATCHES;
  239.   end;
  240.  
  241.   for i := Low(cmds) to High(cmds) do
  242.   begin
  243.     UD2_RunCMD(cmds[i]);
  244.   end;
  245. end;
  246.  
  247. procedure TUD2MainForm.FormDestroy(Sender: TObject);
  248. var
  249.   i: integer;
  250. begin
  251.   if Assigned(ud2) then ud2.Free;
  252.   for i := 0 to TasksListView.Items.Count-1 do
  253.   begin
  254.     TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free;
  255.   end;
  256. end;
  257.  
  258. procedure TUD2MainForm.CheckForErrors;
  259. begin
  260.   ErrorsTabSheet.TabVisible := ud2.Errors.Count > 0;
  261.   if ErrorsTabSheet.TabVisible then
  262.   begin
  263.     ErrorsMemo.Lines.Assign(ud2.Errors);
  264.     PageControl1.ActivePage := ErrorsTabSheet;
  265.   end;
  266. end;
  267.  
  268. procedure TUD2MainForm.LoadDetectedIDs;
  269. var
  270.   i, j: integer;
  271.   pl: TUD2Plugin;
  272.   ude: TUD2IdentificationEntry;
  273. begin
  274.   IdentificationsListView.Clear;
  275.   for i := 0 to ud2.LoadedPlugins.Count-1 do
  276.   begin
  277.     pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
  278.     for j := 0 to pl.DetectedIdentifications.Count-1 do
  279.     begin
  280.       ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
  281.       with IdentificationsListView.Items.Add do
  282.       begin
  283.         Caption := pl.PluginName;
  284.         if ude.DynamicDataUsed then
  285.           SubItems.Add(ude.DynamicData)
  286.         else
  287.           SubItems.Add('');
  288.         SubItems.Add(pl.IdentificationMethodName);
  289.         SubItems.Add(ude.IdentificationString);
  290.         SubItems.Add(GUIDToString(pl.PluginGUID));
  291.       end;
  292.     end;
  293.   end;
  294.  
  295.   for i := 0 to IdentificationsListView.Columns.Count-1 do
  296.   begin
  297.     IdentificationsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER;
  298.   end;
  299. end;
  300.  
  301. procedure TUD2MainForm.LoadINITemplate;
  302. var
  303.   i, j: integer;
  304.   pl: TUD2Plugin;
  305.   ude: TUD2IdentificationEntry;
  306.   idNames: TStringList;
  307. begin
  308.   IniTemplateMemo.Clear;
  309.   IniTemplateMemo.Lines.Add('[ExampleTask1]');
  310.   IniTemplateMemo.Lines.Add('; Description: Optional but recommended');
  311.   IniTemplateMemo.Lines.Add('Description=Run Task #1');
  312.   IniTemplateMemo.Lines.Add('; WarnIfNothingMatches: Warns when no application was launched. Default: false.');
  313.   IniTemplateMemo.Lines.Add('WarnIfNothingMatches=false');
  314.   IniTemplateMemo.Lines.Add('; Optional: IconDLL + IconIndex');
  315.   IniTemplateMemo.Lines.Add('Icon=%SystemRoot%\system32\Shell32.dll,3');
  316.   IniTemplateMemo.Lines.Add('; Optional: Can be true or false');
  317.   IniTemplateMemo.Lines.Add(TagCloseAfterLaunching+'=true');
  318.  
  319.   for i := 0 to ud2.LoadedPlugins.Count-1 do
  320.   begin
  321.     pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
  322.     for j := 0 to pl.DetectedIdentifications.Count-1 do
  323.     begin
  324.       ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
  325.       IniTemplateMemo.Lines.Add(Format('; %s', [ude.Plugin.PluginName]));
  326.  
  327.       idNames := TStringList.Create;
  328.       try
  329.         ude.GetIdNames(idNames);
  330.         if idNames.Count >= 1 then
  331.           IniTemplateMemo.Lines.Add(idNames.Strings[0]+'=calc.exe');
  332.       finally
  333.         idNames.Free;
  334.       end;
  335.  
  336.     end;
  337.   end;
  338. end;
  339.  
  340. procedure TUD2MainForm.LoadLoadedPluginList;
  341. resourcestring
  342.   LNG_MS = '%dms';
  343. var
  344.   i: integer;
  345.   pl: TUD2Plugin;
  346. begin
  347.   LoadedPluginsListView.Clear;
  348.   for i := 0 to ud2.LoadedPlugins.Count-1 do
  349.   begin
  350.     pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
  351.     with LoadedPluginsListView.Items.Add do
  352.     begin
  353.       Caption := pl.PluginDLL;
  354.       SubItems.Add(pl.PluginVendor);
  355.       SubItems.Add(pl.PluginName);
  356.       SubItems.Add(pl.PluginVersion);
  357.       SubItems.Add(pl.IdentificationMethodName);
  358.       if pl.AcceptsDynamicRequests then
  359.         SubItems.Add('Yes')
  360.       else
  361.         SubItems.Add('No');
  362.       SubItems.Add(IntToStr(pl.DetectedIdentifications.Count));
  363.       SubItems.Add(Format(LNG_MS, [Max(1,pl.time)])); // at least show 1ms, otherwise it would look unloggical
  364.       SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed);
  365.       SubItems.Add(pl.PluginGUIDString);
  366.     end;
  367.   end;
  368.  
  369.   for i := 0 to LoadedPluginsListView.Columns.Count-1 do
  370.   begin
  371.     LoadedPluginsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER;
  372.   end;
  373. end;
  374.  
  375. procedure TUD2MainForm.TasksListViewDblClick(Sender: TObject);
  376. var
  377.   obj: TUD2ListViewEntry;
  378. begin
  379.   if TasksListView.ItemIndex = -1 then exit;
  380.   obj := TUD2ListViewEntry(TasksListView.Selected.Data);
  381.   DoRun(obj.ShortTaskName);
  382.   if obj.CloseAfterLaunching then Close;
  383. end;
  384.  
  385. procedure TUD2MainForm.TasksListViewKeyPress(Sender: TObject; var Key: Char);
  386. begin
  387.   if Key = #13 then
  388.   begin
  389.     TasksListViewDblClick(Sender);
  390.   end;
  391. end;
  392.  
  393. procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject);
  394. var
  395.   cmd: TUD2Command;
  396. begin
  397.   cmd.executable := ud2.IniFileName;
  398.   cmd.runAsAdmin := false;
  399.   cmd.runInOwnDirectory := false;
  400.   cmd.windowMode := SW_NORMAL;
  401.   UD2_RunCMD(cmd);
  402. end;
  403.  
  404. procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject);
  405. begin
  406.   if CompatSaveDialogExecute(SaveDialog1) then
  407.   begin
  408.     IniTemplateMemo.Lines.SaveToFile(SaveDialog1.FileName);
  409.   end;
  410. end;
  411.  
  412. procedure TUD2MainForm.URLLabelClick(Sender: TObject);
  413. var
  414.   cmd: TUD2Command;
  415. begin
  416.   cmd.executable := TLabel(Sender).Caption;
  417.   if Pos('@', cmd.executable) > 0 then
  418.     cmd.executable := 'mailto:' + cmd.executable
  419.   else
  420.     cmd.executable := 'http://' + cmd.executable;
  421.  
  422.   cmd.runAsAdmin := false;
  423.   cmd.runInOwnDirectory := false;
  424.   cmd.windowMode := SW_NORMAL;
  425.  
  426.   UD2_RunCMD(cmd);
  427. end;
  428.  
  429. procedure TUD2MainForm.TasksPopupMenuPopup(Sender: TObject);
  430. begin
  431.   Run1.Enabled := TasksListView.ItemIndex <> -1;
  432.   Properties1.Enabled := TasksListView.ItemIndex <> -1;
  433. end;
  434.  
  435. procedure TUD2MainForm.Run1Click(Sender: TObject);
  436. begin
  437.   TasksListViewDblClick(Sender);
  438. end;
  439.  
  440. procedure TUD2MainForm.Properties1Click(Sender: TObject);
  441. var
  442.   obj: TUD2ListViewEntry;
  443. begin
  444.   if TasksListView.ItemIndex = -1 then exit;
  445.   obj := TUD2ListViewEntry(TasksListView.Selected.Data);
  446.   if obj.TaskPropertiesForm = nil then
  447.   begin
  448.     obj.TaskPropertiesForm := TUD2TaskPropertiesForm.Create(Self, ud2, obj.ShortTaskName);
  449.   end;
  450.   obj.TaskPropertiesForm.Show;
  451. end;
  452.  
  453. procedure TUD2MainForm.IdentificationsPopupMenuPopup(Sender: TObject);
  454. begin
  455.   CopyTaskDefinitionExample1.Enabled := IdentificationsListView.ItemIndex <> -1;
  456. end;
  457.  
  458. procedure TUD2MainForm.CopyTaskDefinitionExample1Click(Sender: TObject);
  459. var
  460.   s: string;
  461. begin
  462.   s := '; '+IdentificationsListView.Selected.Caption+#13#10+
  463.        IdentificationsListView.Selected.SubItems[0] + ':' + IdentificationsListView.Selected.SubItems[1] + '=calc.exe'+#13#10+
  464.        #13#10+
  465.        '; Alternatively:'+#13#10+
  466.        IdentificationsListView.Selected.SubItems[2] + ':' + IdentificationsListView.Selected.SubItems[1] + '=calc.exe'+#13#10;
  467.   Clipboard.AsText := s;
  468. end;
  469.  
  470. procedure TUD2MainForm.ListViewCompare(Sender: TObject; Item1,
  471.   Item2: TListItem; Data: Integer; var Compare: Integer);
  472. var
  473.   ListView: TVTSListView;
  474. begin
  475.   ListView := Sender as TVTSListView;
  476.   if ListView.CurSortedColumn = 0 then
  477.   begin
  478.     Compare := AlphaNumCompare(Item1.Caption, Item2.Caption);
  479.   end
  480.   else
  481.   begin
  482.     Compare := AlphaNumCompare(Item1.SubItems[ListView.CurSortedColumn-1],
  483.                                Item2.SubItems[ListView.CurSortedColumn-1]);
  484.   end;
  485.   if ListView.CurSortedDesc then Compare := -Compare;
  486. end;
  487.  
  488. procedure TUD2MainForm.Button3Click(Sender: TObject);
  489. begin
  490.   VTS_CheckUpdates('userdetect2', VersionLabel.Caption);
  491. end;
  492.  
  493. procedure TUD2MainForm.LoadedPluginsPopupMenuPopup(Sender: TObject);
  494. begin
  495.   MenuItem1.Enabled := LoadedPluginsListView.ItemIndex <> -1;
  496. end;
  497.  
  498. procedure TUD2MainForm.MenuItem1Click(Sender: TObject);
  499. var
  500.   s: string;
  501. begin
  502.   s := '; ' + LoadedPluginsListView.Selected.SubItems.Strings[6];
  503.   Clipboard.AsText := s;
  504. end;
  505.  
  506. procedure TUD2MainForm.Run;
  507. resourcestring
  508.   LNG_SYNTAX = 'Syntax: %s [TaskDefinitionFile [/T TaskName] | /C IdentificationTerm [Command] | /?]';
  509. var
  510.   LoadedIniFile: string;
  511. begin
  512.   ExitCode := EXITCODE_OK;
  513.  
  514.   if ((ParamCount = 1) and CheckBoolParam(1, '?')) or
  515.      (CheckBoolParam(2, 'T') and (ParamCount > 3)) or
  516.      (CheckBoolParam(1, 'C') and (ParamCount > 3)) or
  517.      (not CheckBoolParam(2, 'T') and not CheckBoolParam(1, 'C') and (ParamCount > 1)) then
  518.   begin
  519.     ExitCode := EXITCODE_SYNTAX_ERROR;
  520.     MessageDlg(Format(LNG_SYNTAX, [GetOwnCmdName]), mtInformation, [mbOK], 0);
  521.  
  522.     Visible := false;
  523.     Close;
  524.     Exit;
  525.   end;
  526.  
  527.   LoadedIniFile := GetIniFileName;
  528.   if LoadedIniFile = '' then
  529.   begin
  530.     Visible := false;
  531.     Close;
  532.     Exit;
  533.   end;
  534.   ud2 := TUD2.Create(LoadedIniFile);
  535.  
  536.   ud2.HandlePluginDir('',        '*.udp');
  537.   ud2.HandlePluginDir('Plugins', '*.udp');
  538.   ud2.HandlePluginDir('Plugins', '*.dll');
  539.  
  540.   if CheckBoolParam(1, 'C') then
  541.   begin
  542.     if ud2.FulfilsEverySubterm(ParamStr(2)) then
  543.     begin
  544.       ExitCode := EXITCODE_OK;
  545.  
  546.       if ParamStr(3) <> '' then
  547.       begin
  548.         UD2_RunCMD(UD2P_DecodeCommand(ParamStr(3)));
  549.       end;
  550.     end
  551.     else
  552.     begin
  553.       ExitCode := EXITCODE_TASK_NOTHING_MATCHES;
  554.     end;
  555.  
  556.     Visible := false;
  557.     Close;
  558.     Exit;
  559.   end
  560.   else if CheckBoolParam(2, 'T') then
  561.   begin
  562.     DoRun(ParamStr(3));
  563.  
  564.     Visible := false;
  565.     Close;
  566.     Exit;
  567.   end
  568.   else
  569.   begin
  570.     LoadTaskList;
  571.     LoadDetectedIDs;
  572.     LoadINITemplate;
  573.     LoadLoadedPluginList;
  574.     LoadDynamicPluginList;
  575.     CheckForErrors;
  576.  
  577.     Visible := true;
  578.     Exit;
  579.   end;
  580. end;
  581.  
  582. procedure TUD2MainForm.FormCreate(Sender: TObject);
  583. begin
  584.   // To avoid accidental change of the default tab from the IDE VCL Designer
  585.   PageControl1.ActivePage := TasksTabSheet;
  586. end;
  587.  
  588. procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject);
  589. var
  590.   p: TUD2Plugin;
  591.   x: TArrayOfString;
  592.   newStuff: boolean;
  593. resourcestring
  594.   LNG_DETECTED_DYNAMICS = 'The plugin returns following identification strings:';
  595. begin
  596.   if DynamicTestPluginComboBox.ItemIndex = -1 then
  597.   begin
  598.     ShowMessage('Please select a plugin that is accepting dynamic requests.');
  599.     exit;
  600.   end;
  601.  
  602.   p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin;
  603.  
  604.   newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, x);
  605.  
  606.   showmessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10));
  607.  
  608.   if newStuff then
  609.   begin
  610.     LoadDetectedIDs;
  611.     LoadINITemplate;
  612.   end;
  613. end;
  614.  
  615. procedure TUD2MainForm.LoadDynamicPluginList;
  616. var
  617.   i: integer;
  618.   p: TUD2Plugin;
  619. begin
  620.   for i := 0 to ud2.LoadedPlugins.Count-1 do
  621.   begin
  622.     p := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
  623.     if p.AcceptsDynamicRequests then
  624.     begin
  625.       DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p);
  626.     end;
  627.   end;
  628. end;
  629.  
  630. end.
  631.