![]() |
Fehler beim Benutzen von DLL Procedure
Liste der Anhänge anzeigen (Anzahl: 2)
Hallo.
Ich habe ein Problem wenn ich eine Procedure benutze welche ich in einer DLL eingetragen habe. Wenn ich die Procedure in der Unit des Programms deklariere und definiere dann funktioniert alles problemlos. Wenn ich sie aber über eine DLL benutze bekomme ich eine Fehlermeldung. das ist die DLL
Delphi-Quellcode:
und ich benutz sie so:
library map;
{ Important note about DLL memory management: ShareMem must be the first unit in your library's USES clause AND your project's (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL--even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. } uses SysUtils, Grids, StdCtrls, Classes; {$R *.res} procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName); var f: TextFile; iTmp, i, k: Integer; strTemp: String; begin AssignFile(f, FileName); Reset(f); with StringGrid do begin // Get number of columns Readln(f, iTmp); ColCount := iTmp; // Get number of rows Readln(f, iTmp); RowCount := iTmp; // loop through cells & fill in values for i := 0 to ColCount - 1 do for k := 0 to RowCount - 1 do begin Readln(f, strTemp); Cells[i, k] := strTemp; end; end; CloseFile(f); end; exports LoadStringGrid; begin end.
Delphi-Quellcode:
in land steht nur welche datei geladen werden muss.... procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName); external 'map.dll' ... LoadStringGrid(frmMapMv.sgMap, land+'.mp'); Die Fehlermeldung ist Zitat:
|
Re: Fehler beim Benutzen von DLL Procedure
Setze mal statt
Delphi-Quellcode:
->
procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName);
Delphi-Quellcode:
und
procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName); stdcall;
Delphi-Quellcode:
->
procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName); external 'map.dll'
Delphi-Quellcode:
procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName); stdcall; external 'map.dll';
|
Re: Fehler beim Benutzen von DLL Procedure
Ein Problem dürfte auch sein, dass TFileName ein String ist. Siehe dazu den Kommentar in der DLL
|
Re: Fehler beim Benutzen von DLL Procedure
Ich verstehe nicht, wieso den Kommentar nie jemand liest, schließlich schreibt Borland/CodeGear/Dingsdatorero den ja nicht umsonst rein *koppschüttel*.
|
Re: Fehler beim Benutzen von DLL Procedure
Vielleicht wusste der TE nicht, dass TFileName im Endeffekt ein String ist.
|
Re: Fehler beim Benutzen von DLL Procedure
Die erste Variante mit stdcall hatt nicht geklappt
Dann zur ShareMem: Wenn ich sie benutze dann kann ich zwar die Dateien laden, aber es kommt dauern nach beenden des Programms Zitat:
Wie ich dass dann mit TFileName ändern kann weis ich nicht. |
Re: Fehler beim Benutzen von DLL Procedure
Verwende PChars anstatt Strings
|
Re: Fehler beim Benutzen von DLL Procedure
Zitat:
|
Re: Fehler beim Benutzen von DLL Procedure
Hallo,
hast du denn nun ShareMem als erstes in Dll UND Programm eingebunden ? Cells[] eines StringGrids ist ja auch vom Typ String Heiko |
Re: Fehler beim Benutzen von DLL Procedure
Alternativ auch
![]() mfG mirage228 |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz