Hallo DelphiPraxis,
ich habe ein kleines Problem beim Aufrufen einer Funktion einer
Dll.
Und zwar programmiere ich gerade ein Updater für die Plugins von DPM un
PE.
So sieht der Code im Moment aus:
Delphi-Quellcode:
procedure FindLoop(
const APath :
string);
var
proc : Pointer;
getinfo : TGetInfo;
text : WideString;
begin
if FindFirst(APath + '
*', faAnyFile, sr) = 0
then
try
repeat
if (sr.
Name <> '
.')
and (sr.
Name <> '
..')
then
begin
if (sr.Attr
and faDirectory) = faDirectory
then
FindLoop(APath + sr.
Name + '
\')
else if ExtractFileExt(sr.
Name) = '
.plg'
then
begin
plg := LoadLibrary(PChar(APath + sr.
Name));
if (plg <> INVALID_HANDLE_VALUE)
and (plg <> 0)
then
begin
case programm
of
pPlainEdit : proc := GetProcAddress(plg, '
PEP_GetInfo');
pDevProjectManager : proc := GetProcAddress(plg, '
DPMP_GetInfo');
end;
if proc =
nil then
begin
FreeLibrary(plg);
end else
begin
getinfo := TGetInfo(proc);
try
// Diese Zeile:
getinfo(PEP_GI_VERSION, text);
ShowMessage(text);
except
on e :
Exception do
begin
ShowMessage(e.
Message);
FreeLibrary(plg);
end;
end;
end;
end;
end;
end;
until FindNext(sr) <> 0;
finally
FindClose(sr);
end;
end;
Ich durchsuche das Pluginverzeichnis nach den Plugins.
Und diese Funktion existiert in der
DLL!
Wenn ich aber "getinfo" aufrufe, bekomme ich eine
AV!
TGetInfo sieht übrigens so aus:
Delphi-Quellcode:
type
TGetInfo = function(InfoId: DWord; var Data: WideString): DWord;
Was sein könnte, dass er mit WideString nicht zurecht kommt, aber ich habe im Forum dannach gesucht, und dort stand das ShareMem nicht benötigt wird?
MfG
xZise