質問

Windows exe ファイルは、そのパスとファイル名を含む、それを呼び出したコマンド文字列にアクセスできます。例えば。 C:\MyApp\MyApp.exe --help.

しかし、これは、経由で呼び出される DLL には当てはまりません。 LoadLibrary. 。DLL がそのパスとファイル名を調べる方法を知っている人はいますか?

具体的には、Delphi ソリューションに興味がありますが、答えはどの言語でもほぼ同じになるのではないかと思います。

役に立ちましたか?

解決

GetModuleFileName を探していると思います。

http://www.swissdelphicenter.ch/torry/showcode.php?id=143:

{
  If you are working on a DLL and are interested in the filename of the
  DLL rather than the filename of the application, then you can use this function:
}

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;

ただし、テストはしていませんが、Delphi を使ってからしばらく経ちました:)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top