遍历菜单
procedure ExplorerMenuItem(MenuHandle: THandle);
var
MenuIndex: Integer;
MenuCaptionArray: array[1..255] of Char;
MenuCaptionString: String;
ItemInfo: TMenuItemInfo;
Buffer: array[0..20] of Char;
begin
for MenuIndex := 0 to GetMenuItemCount(MenuHandle) - 1 do begin
//Something todo. Here we get the caption
GetMenuString(MenuHandle, MenuIndex, @MenuCaptionArray, 255, MF_BYPOSITION);
MenuCaptionString := MenuCaptionArray;
SetLength(MenuCaptionString,StrLen(PChar(MenuCaptionString)));
ShowMessage('Menu Caption: ' + MenuCaptionString);
//Get caption ends here.
ItemInfo.cbSize := SizeOf(TMenuItemInfo);
ItemInfo.fMask := MIIM_SUBMENU;
ItemInfo.dwTypeData := Buffer;
ItemInfo.cch := SizeOf(Buffer);
GetMenuItemInfo(MenuHandle, MenuIndex, True, ItemInfo);
//submenu, calls itself
if ItemInfo.hSubMenu <> 0 then begin
ExplorerMenuItem(ItemInfo.hSubMenu);
end;
end;
end;
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步