문제

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