gpt4 book ai didi

delphi - 如何通过ShellExecuteEx打开字体文件?

转载 作者:行者123 更新时间:2023-12-02 07:48:40 25 4
gpt4 key购买 nike

我得到了一个名为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;

收到错误:参数不正确

我想知道如何解决这个问题?我错过了一些参数吗?

更新:

如何获取字体文件绝对 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com