Autor Beitrag
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Sa 04.06.05 13:46 
Moin... ;)

Ich habe folgende Funktion in meinem Programm:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function MyChecking(p: PMediaPlayer): DWORD; stdcall;
begin
p.Play;
end;


Diese rufe ich folgendermaßen auf:
ausblenden Delphi-Quelltext
1:
BeginThread(nil0, @MyChecking, @MediaPlayer1, 0, ID);					


Führe ich das Programm aus, bekomme ich an entsprechender Stelle eine Access Violation. Lass' ich dagegen jetzt die Funktion weg und schreib:
ausblenden Delphi-Quelltext
1:
2:
//BeginThread(nil, 0, @MyChecking, @MediaPlayer1, 0, ID);
MediaPlayer1.Play


...dann funktioniert alles. Es muss also irgendwas mit dem Thread zu tun haben. :nixweiss:

Danke schonmal für alle Antworten. ;)
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 04.06.05 13:54 
Versuch's mal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function MyChecking(p: Pointer): Integer;
begin
    TMediaPlayer(p).Play;
end;


Aufruf mit:
ausblenden Delphi-Quelltext
1:
BeginThread(nil0, @MyChecking, Pointer(MediaPlayer1), 0, ID);					


P.S.: BTW: VCL + Multithreading - Synchronize = Nono!

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Sa 04.06.05 14:01 
So passiert gar nichts. Wenn ich jedoch das stdcall; hintendran schreib kommt wieder eine Access Violation... :cry: :gruebel:
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 04.06.05 15:41 
BeginThread ist nur ein Wrapper für die API Suche im MSDN CREATETHREAD und wenn du BeginThread nimmst darfst du kein stdcall benutzen. Die AV rührt wohl eher hier p.Play; her. Wie man Parameter an einen Thread übergibt, kannst du in meinem Tutorial nachlesen.
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 05.06.05 11:56 
user profile iconLuckie hat folgendes geschrieben:
BeginThread ist nur ein Wrapper für die API Suche im MSDN CREATETHREAD und wenn du BeginThread nimmst darfst du kein stdcall benutzen. Die AV rührt wohl eher hier p.Play; her.

Gut. Okay. Danke. ;)

user profile iconLuckie hat folgendes geschrieben:
Wie man Parameter an einen Thread übergibt, kannst du in meinem Tutorial nachlesen.

Dein Tutorial hab ich hier in ausgedruckter Form vor mir liegen. Werd mir das mit den Parametern nochmal ansehen. :?