将图标添加到系统映像列表中 [英] Adding icon into system imagelist
本文介绍了将图标添加到系统映像列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了NSE,我需要制作叠加图标.在xp上,它工作正常.在win 7上,当我尝试将图标添加到系统映像列表SHIL_JUMBO时,结果为-1.为什么? P.S.我使用接口IShellIconOverlay
I wrote NSE, I need make overlay icon. On xp it worked fine. On win 7 when I try add icon into system imagelist SHIL_JUMBO I take result -1. Why? P.S. I use interface IShellIconOverlay
推荐答案
这是我在Delphi上的示例
it''s my example on Delphi
function GetImageListSH(SHIL_FLAG:Cardinal): HIMAGELIST;
type
_SHGetImageList = function (iImageList: integer; const riid: TGUID; var ppv: Pointer): hResult; stdcall;
var
Handle: THandle;
SHGetImageList: _SHGetImageList;
begin
Result:= 0;
Handle:= LoadLibrary('Shell32.dll');
if Handle<>S_OK then
try
SHGetImageList:=GetProcAddress(Handle, PChar(727));
if Assigned(SHGetImageList) and (Win32Platform=VER_PLATFORM_WIN32_NT) then
SHGetImageList(SHIL_FLAG, IID_IImageList, Pointer(Result));
finally
FreeLibrary(Handle);
end;
end;
procedure TFmMain.bTestClick(Sender: TObject);
var
ImageList: HIMAGELIST;
Ico: TIcon;
Res: Integer;
begin
if odPicture.Execute then
begin
ImageList := GetImageListSH(SHIL_JUMBO);
Ico := TIcon.Create;
try
ico.LoadFromFile(odPicture.FileName);
Res := ImageList_AddIcon(ImageList,Ico.Handle);
ShowMessage(IntToStr(Res)); //Res always equal -1
finally
ico.Free;
end;
end;
end;
ImageList_Replace(-1,HIcon)会将图标添加到ImageList的END. .
ImageList_Replace (-1,HIcon) will add an icon to the END of the ImageList...
这篇关于将图标添加到系统映像列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文