The implementation of TEnumFormats.SomeFiles seems to be wrong.
The MSDN docs for the DROPFILES structure state for pFiles:
The offset of the file list from the beginning of this structure, in bytes.
This doesn't match the implementation for the DELPHI_UNICODE case:
{$IFNDEF DELPHI_UNICODE}
Filename := PChar(DropFiles) + DropFiles^.pFiles;
{$ENDIF}
{$IFDEF DELPHI_UNICODE}
Filename := PChar(DropFiles) + (DropFiles^.pFiles div 2);
{$ENDIF}
Actually, the offset to the file list doesn't depend on the size of a character. It is always the same in a Unicode or non-Unicode Delphi.
My working implementation looks like this:
function TEnumFormats.SomeFiles(var Files: TStringList): boolean;
var
DropFiles:PDropFiles;
Filename:PByte;
s:string;
H:hGlobal;
begin
FFiles.Clear;
H := GlobalHandle;
if H <> 0 then
begin
DropFiles := PDropFiles(GlobalLock(H));
try
Filename := PByte(DropFiles) + DropFiles^.pFiles;
while (Filename^ <> 0) do
begin
if (DropFiles^.fWide) then // -> NT4 compatability
begin
{$IFNDEF DELPHI_UNICODE}
s := WideCharToString(PWideChar(Filename));
inc(Filename, (Length(s) + 1) * 2);
{$ENDIF}
{$IFDEF DELPHI_UNICODE}
s := PChar(Filename);
inc(Filename, (Length(s) + 1));
{$ENDIF}
end
else
begin
s := AnsiStrings.StrPas(PAnsiChar(Filename));
inc(Filename, Length(s) + 1);
end;
Files.Add(s);
end;
finally
GlobalUnlock(H);
end;
end;
Result := (Files.count > 0);
end;