Oppure

Loading
09/06/12 13:31
simo12
Ciao a tutti volevo fare su Delphi una sorta di media player ma quando carico un file da far leggere mi da l' errore 'access violation at address 0045ADAA in module project3.exe. Read of address 00000260
Questo è il codice che ho implementato, i file sono in formato wave

implementation

{$R *.dfm}



procedure TForm4.SfogliaClickClick(Sender: TObject); //bottone che fa cercare il file

var
files:array[1..1000] of string;
filenames:array[1..1000] of string;
i:integer;
begin
OpenDialog1.Execute;
For i:=0 To OpenDialog1.Files.Count-1 Do
begin
files[i]:= OpenDialog1.Files.Strings[i];
filenames[i]:= ExtractFileName(OpenDialog1.Files.Strings[i]);
ListBox1.Items.Add(files[i]);
ListBox2.Items.Add(filenames[i]);
end;

end;

procedure TForm4.MP1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
begin
MP1.FileName:=FileNames[i];
MP1.Open;
MP1.Play;
end;
end.

Grazie :)
aaa
09/06/12 13:58
smanettone83
Postato originariamente da simo12:

Ciao a tutti volevo fare su Delphi una sorta di media player ma quando carico un file da far leggere mi da l' errore 'access violation at address 0045ADAA in module project3.exe. Read of address 00000260
Questo è il codice che ho implementato, i file sono in formato wave

implementation

{$R *.dfm}



procedure TForm4.SfogliaClickClick(Sender: TObject); //bottone che fa cercare il file

var
files:array[1..1000] of string;
filenames:array[1..1000] of string;
i:integer;
begin
OpenDialog1.Execute;
For i:=0 To OpenDialog1.Files.Count-1 Do
begin
files[i]:= OpenDialog1.Files.Strings[i];
filenames[i]:= ExtractFileName(OpenDialog1.Files.Strings[i]);
ListBox1.Items.Add(files[i]);
ListBox2.Items.Add(filenames[i]);
end;

end;

procedure TForm4.MP1Click(Sender: TObject; Button: TMPBtnType;
var DoDefault: Boolean);
begin
MP1.FileName:=FileNames[i];
MP1.Open;
MP1.Play;
end;
end.

Grazie :)


prova piu semplicemente cosi:

var
i:integer;
begin
OpenDialog1.Execute;
For i:=0 To OpenDialog1.Files.Count-1 Do
begin
ListBox1.Items.Add(OpenDialog1.Files[i]);
ListBox2.Items.Add(extractfilename(OpenDialog1.Files[i]));
end;
end;
aaa