Get module filename of current process

Posted in System info

The GetModuleFileName function retrieves the full path and filename for the executable file containing the specified module.

procedure TForm1.Button1Click(Sender: TObject);
var
  FileName: array[0..128] of Char;
begin
  GetModuleFileName(hInstance, FileName, 128);
  Label1.Caption := FileName;
end;