Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Unit4.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations) (download) (as text)
Sat Aug 15 03:06:09 2015 UTC (8 years, 6 months ago) by yamat0jp
File MIME type: text/x-pascal
File size: 2354 byte(s)
タグ読み取りに使用するユニットを変更しました。現在Androidでは利用できませんが、書き換えをして使えるようにしようと思います。
1 unit Unit4;
2
3 interface
4
5 uses
6 System.Classes, System.SysUtils;
7
8 type
9 TSearchMP3 = class(TThread)
10 private
11 { Private 宣言 }
12 protected
13 procedure Execute; override;
14 end;
15
16 implementation
17
18 {
19 重要: ビジュアル コンポーネントにおけるオブジェクトのメソッドとプロパティは、Synchronize を使って
20 呼び出されるメソッドでのみ使用できます。たとえば、次のようになります。
21
22 Synchronize(UpdateCaption);
23
24 UpdateCaption は、たとえば次のようなコードになります。
25
26 procedure TSeachMP3.UpdateCaption;
27 begin
28 Form1.Caption := 'スレッドで更新されました';
29 end;
30
31 あるいは
32
33 Synchronize(
34 procedure
35 begin
36 Form1.Caption := '無名メソッドを通じてスレッドで更新されました'
37 end
38 )
39 );
40
41 ここでは、無名メソッドが渡されています。
42
43 同様に、開発者は上記と同じようなパラメータで Queue メソッドを呼び出すことができます。
44 ただし、別の TThread クラスを第 1 パラメータとして渡し、呼び出し元のスレッドを
45 もう一方のスレッドでキューに入れます。
46
47 }
48
49 uses Unit2, Unit1, Unit3;
50
51 { TSearchMP3 }
52
53 procedure TSearchMP3.Execute;
54 var
55 depth: integer;
56 i, k: integer;
57 s: string;
58 temp: TStringList;
59 procedure Add(const Dir: string);
60 var
61 s1, s2: TSearchRec;
62 st: string;
63 i, j: integer;
64 begin
65 if Dir = '' then
66 st := ''
67 else
68 st := IncludeTrailingPathDelimiter(Dir);
69 i := FindFirst(st + '*', faDirectory, s1);
70 j := FindFirst(st + '*.mp3', faNormal, s2);
71 try
72 while i = 0 do
73 begin
74 if (s1.Name <> '.') and (s1.Name <> '..') then
75 temp.Add(st + s1.Name + '|' + (depth + 1).ToString);
76 i := FindNext(s1);
77 end;
78 while j = 0 do
79 begin
80 Form1.list.Add(st+s2.Name);
81 j := FindNext(s2);
82 end;
83 finally
84 FindClose(s1);
85 FindClose(s2);
86 end;
87 end;
88
89 begin
90 { スレッドとして実行したいコードをここに記述してください }
91 temp:=TStringList.Create;
92 try
93 temp.NameValueSeparator := '|';
94 temp.Add('e:|0');
95 i := Form2.PopupBox1.Text.ToInteger;
96 k := 0;
97 while (Terminated = false) and (k < temp.Count) do
98 begin
99 depth := temp.ValueFromIndex[k].ToInteger;
100 if depth < i then
101 Add(temp.Names[k]);
102 inc(k);
103 end;
104 Synchronize(Form1.Id3Tag);
105 finally
106 temp.Free;
107 end;
108 end;
109
110 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26