Autor Beitrag
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Di 26.08.03 18:17 
Hallo,

Warum funktioniert folgender Aufruf nicht (ich kriege immer einen Anwendungsfehler im Modul "Standard.ccp")?

Das ist die DLL Prozedur:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
//Graustufen
procedure GrayScale(var Picture: TBitMap); stdcall; Export;
var
p0:pbytearray;
Gray,x,y: Integer;
begin
  for y:=0 to Picture.Height-1 do
  begin
    p0:=Picture.scanline[y];
    for x:=0 to Picture.Width-1 do
    begin
      Gray:=Round(p0[x*3]*0.3+p0[x*3+1]*0.59+p0[x*3+2]*0.11);
      p0[x*3]:=Gray;
      p0[x*3+1]:=Gray;
      p0[x*3+2]:=Gray;
    end;
  end;
end;


und das der Aufruf in meinem Programm:
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:
24:
25:
procedure Tmainform.startbtnClick(Sender: TObject);
//Funktionen und Prozeduren der DLL 
type
  TEffectProc = procedure (var Picture: TBitMap);
  stdcall; //Führ den Effekt aus
var
  hPlugIn: HMODULE;
  Effectproc: TEffectProc;
  s: string;
  bmp: TBitMap;
begin
   hPlugIn := LoadLibrary(pchar(extractfilepath(paramstr(0))+'PlugIns\Standard.ccp'));
   if hPlugIn <> 0 then
   begin @Effectproc := GetProcAddress(hPlugIn, 'GrayScale');
     if @Effectproc <> nil then
     begin
      bmp := tBitMap.create;
      bmp.assign(img.picture.bitmap);
      Effectproc(bmp);
      img.picture.bitmap.assign(bmp);
      bmp.free;
     end;
    end;
  FreeLibrary(hPlugIn);
end;


Also, wer sieht´s?
Bin für jede Hilfe dankbar.

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 26.08.03 18:57 
ccp? Was ist das für ein Datei? Und welcher von deinen Code-Snippets ist in dieser ominösen cccp-Datei?
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 27.08.03 09:07 
Hi!

Wieso nennst du deine DLL denn ccp?

Anyway, dein Problem hat höchstwahrscheinlich damit zu tun, dass dynamische Strukturen wie Strings & Objekte (hier: dein Objekt Picture von Typ TBitmap)nicht so einfach an DLLs übergeben werden können. Suche mal hier im Forum und/oder in der Delphi-Hilfe nach "Shared-Memory-Manager".

Cu,
Udontknow
GSE Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Mi 27.08.03 13:37 
Udontknow hat folgendes geschrieben:
Wieso nennst du deine DLL denn ccp?

Luckie hat folgendes geschrieben:
ccp? Was ist das für ein Datei?

Darf ich das nicht?
Ich hab die dll einfach ccp genannt, da es sich um ein PlugIn für mein Programm handelt und damit man besser zwischen System-DLL und PlugIn unterscheiden kann, nicht verboten oder?

Udontknow hat folgendes geschrieben:
Suche mal hier im Forum und/oder in der Delphi-Hilfe nach "Shared-Memory-Manager".

Werd ich machen. Danke erstmal.

[edit]Habe jetzt die Unit sharemem eingebunden und es funktioniert aber jetzt bekommen ich beim Beenden des Programms immer Runtime Error 216? Wieso? Wo ist da der Fehler? Danke für eure Hilfe![/edit]

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
GSE Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Mi 27.08.03 14:00 
Besagter Runtime Error tritt allerdings nur auf, wenn ich in meiner Anwendung ShareMem mit einbinde. Wenn ich raus lasse läuft es anstandslos durch aber ohne ShareMem kann ich ja keine BitMaps mit Dll´s "tauschen". Was soll ich machen?

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 27.08.03 14:03 
Sorry, Glaskugel defekt. Ohne konnte ich leider nicht feststellen, dass deine DLL nicht die strandardmäßige Endung dll, sonder ccp hat.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 27.08.03 15:52 
GSE hat folgendes geschrieben:
Was soll ich machen?

Du musst ShareMem als aller erste Unit im Hauptmodul (.dpr) des Programms und der DLL hinzufügen. Sollte nämlich eine andere Unit vorher eingebunden werden, verwendet diese für ihrer Initialisierung den normalen Speichermanager. Beim Finalize diese Unit ist aber der ShareMem Speichermanager geladen und bumm.

_________________
Ist Zeit wirklich Geld?