Vra

'n Windows exe-lêer het toegang tot die command string wat dit vir drie maande, insluitend sy pad en lêernaam. bv. C:\MyApp\MyApp.exe --help.

Maar dit is nie so 'n dll opgeroep via LoadLibrary. Is daar iemand weet van 'n manier vir 'n dll om uit te vind wat sy pad en lêernaam is?

spesifiek Ek stel belang in 'n Delphi oplossing, maar ek vermoed dat die antwoord pretty much dieselfde vir enige taal sal wees.

Was dit nuttig?

Oplossing

Ek dink jy soek 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;

Untested al is, was 'n paar keer sedert ek saam met Delphi:)

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top