获得外部程序的图标
function GetFileIcon(const Filename:String; SmallIcon:Boolean):HICON;
var info:TSHFILEINFO;
Flag: Integer;
begin
if SmallIcon then Flag:=(SHGFI_SMALLICON or SHGFI_ICON)
else Flag:=(SHGFI_LARGEICON or SHGFI_ICON);
SHGetFileInfo(Pchar(Filename),0,info,Sizeof(info),Flag);
Result:=info.hIcon;
end;
function GetFileIcon(const Filename:String; SmallIcon:Boolean):HICON;
var info:TSHFILEINFO;
Flag: Integer;
begin
if SmallIcon then Flag:=(SHGFI_SMALLICON or SHGFI_ICON)
else Flag:=(SHGFI_LARGEICON or SHGFI_ICON);
SHGetFileInfo(Pchar(Filename),0,info,Sizeof(info),Flag);
Result:=info.hIcon;
end;
在任务栏上显示了的、运行中程序的图标;我现在可以把每个程序标题栏
上的Caption取出来,怎么得到图标?谢谢
假设WND是你取得的窗口的句柄(怎么取,k@#$%^&*,FindWindow相信你会用吧
function MyGetWindowIcon(wnd:hwnd):hicon;
begin
result:=getclasslong(wnd,gcl_hicon);
if result=0 then
result:=sendmessage(wnd,wm_geticon,icon_big,0);
end;
//返回值:
0: 表示失败,取不到图标
非0:成功,取到图标用法:
var
ico:hicon;
begin
ico:=myGetWindowIcon(wnd);
if ico<>0 then
image1.picture.icon.handle:=ico
else
showmessage('this window has no icon');
end;--------------------------------
风过西窗客渡舟船无觅处
年年一川新草遥看却似旧
以显示出来,有时显示的不是选定的程序的图标,更多的是根本就不能显示~~
而改成 Buttonx.Glyph.Handle:=MyGetWindowIcon(wnd); 就根本显示不出来~~继续顶顶~~~~~~
Wnd:=findwindow(此处加上你自己的代码);
Wnd:=GetParent(Wnd);
ico:=MyGetWindowIcon(Wnd);
-------------------------------------------------------------------
风过西窗客渡舟船无觅处
年年一川新草遥看却似旧