Enumerating RCData resources from the EXE file which has been launched I am running Delphi XE6.

I recently integrated all of my read-only language INI files into the executables.

As a consequence, I need to enumerate RCData resources (and then simply filter out the languages).

I stumbled across solution, which I lightly changed into this form:

function EnumRCDataProc(hModule: HMODULE; lpszType, lpszName: PChar; lParam: NativeInt): BOOL; stdcall;
begin
  TStrings(lParam).Add(lpszName);
  Result := True;
end;

function EnumerateResourceNames: string;

var
  ExecutableHandle: HMODULE;
  ResourcesList: TStringList;

begin
  ExecutableHandle := LoadLibrary(PChar(Application.ExeName));
  try
    ResourcesList := TStringList.Create;
    try
      EnumResourceNames(ExecutableHandle, RT_RCDATA, @EnumRCDataProc, NativeInt(ResourcesList));
      Result := ResourcesList.Text;
    finally
      ResourcesList.Free;
    end;
  finally
    FreeLibrary(ExecutableHandle);
  end;
end;


It is indeed working. Do you see any possible problems?
The code is mostly fine but there a couple of minor issues:


The documentation for EnumResNameProc explains that lpszType and lpszName could be IDs rather than strings. Use the helper function Is_IntResource from the Windows unit to identify such IDs and treat accordingly.
Using LoadLibrary is fine, but it will result in code in the DLL being executed. Instead you are better to use LoadLibraryEx passing the LOAD_LIBRARY_AS_DATAFILE or LOAD_LIBRARY_AS_IMAGE_RESOURCE for the flags.