Tips: get the filename of current exe file or dll

It is good to keep some programming tips we used.

To get the filename of the application, most of the time you can call:

sFileName := Application.ExeName; // or sFileName := ParamStr(0);

Perhaps 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 Sto_GetModuleName: String;
  szFileName: array[0..MAX_PATH] of Char;
  GetModuleFileName(hInstance, szFileName, MAX_PATH);
  Result := szFileName;

The above is from