我得到名为FontPIDL的字体文件的绝对PIDL

我用下面的代码打开它:
变种
ShExeInfo:SHELLEXECUTEINFO;

begin
    ZeroMemory(@ShExeInfo, SizeOf(ShExeInfo));

    ShExeInfo.cbSize := SizeOf(ShExeInfo);
    ShExeInfo.lpVerb := 'Open';
    ShExeInfo.lpIDList := FontPIDL;
    ShExeInfo.nShow := SW_SHOWNORMAL;
    ShExeInfo.fMask := SEE_MASK_IDLIST;
end;


出现错误:The parameter is incorrect

我想知道如何解决它?我错过了一些参数吗?

更新:

我如何获得字体文件绝对PIDL:

var
  psfDeskTop : IShellFolder;
  psfFont : IShellFolder;
  pEnumList : IEnumIdList;
  pidFont : PItemIdList;
  pidChild : PItemIdList;
  pidAbFont : PItemIdList;
  FontPath : array[0..MAX_PATH - 1] of Char;
  pchEaten, dwAttributes, ItemsFetched : ULONG;

begin
  FillChar(FontPath, sizeof(FontPath), #0);
  SHGetSpecialFolderPath(0, FontPath, CSIDL_FONTS, False);
  SHGetDesktopFolder(psfDeskTop);
  psfDeskTop.ParseDisplayName(0, nil, FontPath, pchEaten, pidFont,
    dwAttributes);
  psfDeskTop.BindToObject(pidFont, nil, IID_IShellFolder, psfFont);
  psfFont.EnumObjects(0, SHCONTF_FOLDERS or SHCONTF_NONFOLDERS or
    SHCONTF_INCLUDEHIDDEN, pEnumList);
  ItemsFetched := 0;
  while pEnumList.Next(1, pidChild, ItemsFetched) = NO_ERROR do
  begin
    pidAbFont := ILCombine(pidFont , pidChild);
    ///... do something
  end;

end;

最佳答案

省略lpVerb分配可使代码工作:

begin
    ZeroMemory(@ShExeInfo, SizeOf(ShExeInfo));
    ShExeInfo.cbSize := SizeOf(ShExeInfo);
    // ShExeInfo.lpVerb := 'Open'; will be fail .
    // use ShExeInfo.lpVerb := '' or ZeroMemory(@ShExeInfo, SizeOf(ShExeInfo)); before
    ShExeInfo.lpIDList := FontPIDL;
    ShExeInfo.nShow := SW_SHOWNORMAL;
    ShExeInfo.fMask := SEE_MASK_IDLIST;
end;

关于delphi - 如何通过ShellExecuteEx打开字体文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13599532/

10-13 01:17