Autor Beitrag
Anisas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 29

Win XP Professional
Delphi 7
BeitragVerfasst: So 13.04.08 14:43 
Hallo zusammen! :)

Ich arbeite an einem Programm, welches mir zu beginn die Bildschirmbreite bzw. Bildschirmhöhe ermitteln soll und mir dann eine DLL aufrufen soll, welche die Werte abfragt. Bei bestimmten Auflösungen sollen bestimmte Bilder geladen werden, jedoch funz das ganze in der DLL nicht.

Mit der Fehlermeldung kann ich leider auch nichts anfangen:
"Access violation at adress 003720EB in module 'Project2.dll'. Read of adress 000002F8."

Hier mal der Code des Programms:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.FormCreate(Sender: TObject);
var breite, hoehe : integer;
begin
   breite := screen.Width;
   hoehe := screen.Height;
   screenmaking(breite,hoehe);
end;


... und hier die DLL:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
library Project2;

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls,
  Unit1 in 'UNIT1.PAS' {Form1};

{$R *.res}

procedure screenmaking(a,b:integer);stdcall;
begin
   if (a = 1280)AND(b = 800) then
   begin
      showmessage('Deine Auflösung: '+inttostr(a)+', '+inttostr(b));
      Form1.IMG.Picture.LoadFromFile('test.bmp');
   end;
end;

exports
   screenmaking;
begin
   showmessage('Programm wird geladen ..');
end.


Was muss ich da ändern, damit er mir das Bild lädt?
Würde mich über jede hilfreiche Antwort freuen! :D

LG, Anisas
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 13.04.08 14:48 
Schon mal versucht mit dem Debugger zu ermitteln in welcher Zeile der Fehler auftritt?

Spontan würde ich mal vermuten: Form1.IMG.Picture.LoadFromFile('test.bmp'); weil ich nirgends sehen kann, dass das Form1 erzeugt wird.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Anisas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 29

Win XP Professional
Delphi 7
BeitragVerfasst: So 13.04.08 15:33 
... muss ich die Form1 auch in der DLL "createn"?
Hab jetzt mal Form1.Create(Application); hinzugefügt - passt das so? Funzen tut's jedenfalls noch nicht. :(
Also nochmal der Code der Proceudre aus der DLL bis jetzt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure screenmaking(a,b:integer);stdcall;
begin
   if (a = 1280)AND(b = 800) then
   begin
      showmessage('Deine Auflösung: '+inttostr(a)+', '+inttostr(b));
      Form1.Create(Application);
      Form1.IMG.Picture.LoadFromFile('test.bmp');
   end;
end;


LG, Anisas
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 13.04.08 17:02 
Woher soll deine DLL das Objekt Form1 kennen? Und zu deinem letzten Posting, nur weil du ein Formobjekt mit gleichen Namen in der DLL erzeugst, ist es noch lange nicht mit dem Formobjekt aus deiner Anwendung identisch.

Ich werfe mal die Frage in den Raum, ob die Funktionalität unbedingt eine DLL erfordert oder wird das nur gemacht, weil es schick aussieht eine DLL im Programmverzeichnis zu haben?
Anisas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 29

Win XP Professional
Delphi 7
BeitragVerfasst: Di 15.04.08 13:50 
... und wie sage ich Delphi, dass er auf auf genau dieses Formblatt zugreifen soll?

Zur 2. Frage:
Es bräuchte dazu keine DLL, nur meine Aufgabenstellung ist es, dass das Programm mit möglichst vielen DLLs arbeitet.
Anisas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 29

Win XP Professional
Delphi 7
BeitragVerfasst: So 20.04.08 11:52 
Weiß denn niemand wie ich in einer DLL auf ein Formblatt einer Unit zugreife?
es wäre sehr nett, wenn mir jemand helfen könnte, bitte.