Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Pfad zu DLL? (https://www.delphipraxis.net/112837-pfad-zu-dll.html)

Weazy 28. Apr 2008 08:40


Pfad zu DLL?
 
Ich arbeite gerad an einem Kontextmenü für den Explorer. Das funktioniert auch ganz gut, doch ich möchte nun den Pfad der DLL herausfinden. Im Forum hier habe ich das hier gefunden:
Delphi-Quellcode:
function GetDllName: string;
begin
  SetLength(Result, 261);
  SetLength(Result, GetModuleFileName(0, @Result[1], Length(Result)));
end;
Das liefer mir immer nur "c:\WINDOWS\explorer.exe", was ja auch verständlich ist da der explorer ja der Host meiner dll ist.

Wie kann ich den Pfad meiner dll herausfinden???

JonnyGuitar 28. Apr 2008 09:02

Re: Pfad zu DLL?
 
moin,

ich bin mir jetzt nicht ganz sicher, aber probier das mal so, sollte klappen :)

Delphi-Quellcode:
function GetModuleName: string;
var
  szFileName: array[0..MAX_PATH] of Char;
begin
  FillChar(szFileName, SizeOf(szFileName), #0);
  GetModuleFileName(hInstance, szFileName, MAX_PATH);
  Result := szFileName;
end;

mfg Jonny

Weazy 28. Apr 2008 09:15

Re: Pfad zu DLL?
 
Perfekt, funktioniert einwandfrei!

Danke vielmals!

JonnyGuitar 28. Apr 2008 09:39

Re: Pfad zu DLL?
 
gern geschehen :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz