Autor Beitrag
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Sa 09.11.02 19:08 
So, hab mal wieder ein Problem:
Ich hab einen Code geschrieben (versucht), der in einem Verzeichnis dlls sucht, diese dynamisch lädt und in einem Prozeduren-Array speichern soll.

Hier mein Code:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var result:TSearchRec;
    counter:integer;
    dllhandle:THandle;
    filename:String;
begin
counter:=0;
if FindFirst(ExtractFilePath(application.ExeName)+'module\*.dll',0,result)=0 then begin
   repeat
         Inc(counter);
         SetLength(modules,counter);
         filename:=(extractfilepath(application.exename)+'\module\'+result.Name);
         dllhandle:=LoadLibrary(@filename);
         @modules[counter-1]:=GetProcAddress(dllhandle,'execute');
         if @modules[counter-1]<>nil then Label1.Caption:=Label1.Caption+result.Name+' ';
         until FindNext(result)<>0;
   FindClose(result);
   end;
end;


Das Problem ist wohl nicht beim Array zu suchen, denn der lädt die DLL gar nicht, das Handle hat als Wert 0 und dem modules wird nil zugewiesen. Was mach ich falsch, oder wie mach ichs besser *g*

Gruß, Uwe
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.11.02 19:20 
Versuch mal:
ausblenden Quelltext
1:
dllhandle:=LoadLibrary(@filename[1]);					

oder schneller ist:
ausblenden Quelltext
1:
dllhandle:=LoadLibrary(pointer(filename));					

Da hier nicht erst UniqueString aufgerufen wird.
UGrohne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Sa 09.11.02 19:25 
Danke für die schnelle Antwort, hab das 2. genommen, und es funktioniert einwandfrei... hehe

Gruß, Uwe
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 09.11.02 19:28 
Na bitte.