Function Enumresname(hmodule:Hmodule;lptype,lpname:Pchar; lparam:longint):Bool;stdcall;
var hicon1:hicon;
hresource:hrsrc;
hmem:hrsrc;
lpresource:pbyte;
listitem:Tlistitem;
begin
hresource:=findresource(hexe,lpname,RT_ICON);
hmem:=loadresource(hexe,hresource);
lpresource:=lockresource(hmem);//返回指向锁定资源头字节的指针
hicon1:=Createiconfromresourceex(lpresource,sizeofresource(hexe,hresource),
True,$0030000,32,32,LR_DEFAULTCOLOR);//从锁定可执行资源创建图标句柄
With Form1 do
begin //显示处理
Ficon.handle:=hicon1;
imagelist1.addicon(ficon);
listitem:=listview1.items.add;
ListItem.ImageIndex := imagelist1.count - 1;
ListItem.caption:= format('图标%d',[imagelist1.count]);
end;
result:=True;
end;文中主要是对.exet和.dll文件中的图标取出来.但是前面几句话看也看不懂,更不知道是怎么个原理取出来的.如果要对其取出的图标进行存储,又该如何写呢?请帮忙把内容具体地解释一下.
var hicon1:hicon;
hresource:hrsrc;
hmem:hrsrc;
lpresource:pbyte;
listitem:Tlistitem;
begin
hresource:=findresource(hexe,lpname,RT_ICON);
hmem:=loadresource(hexe,hresource);
lpresource:=lockresource(hmem);//返回指向锁定资源头字节的指针
hicon1:=Createiconfromresourceex(lpresource,sizeofresource(hexe,hresource),
True,$0030000,32,32,LR_DEFAULTCOLOR);//从锁定可执行资源创建图标句柄
With Form1 do
begin //显示处理
Ficon.handle:=hicon1;
imagelist1.addicon(ficon);
listitem:=listview1.items.add;
ListItem.ImageIndex := imagelist1.count - 1;
ListItem.caption:= format('图标%d',[imagelist1.count]);
end;
result:=True;
end;文中主要是对.exet和.dll文件中的图标取出来.但是前面几句话看也看不懂,更不知道是怎么个原理取出来的.如果要对其取出的图标进行存储,又该如何写呢?请帮忙把内容具体地解释一下.
解决方案 »
- 如何用fastreport3.0的chart不支持带聚合运算的Y轴,有没有高手可以解决?
- 请问dxtreelist怎么实现按数字大小进行排序?
- 请教高手关于跨表查询问题.有学生表和考勤表,学生表中考勤卡号和考勤表中的考勤卡号是一一对应的,现在对考勤表按学生的学号,姓名,班级,考
- 在用checkbox 时遇到的一个问题???
- 在《程序员增值合订本》一书附带的DELPHI7为何不能安装!!!!!进来有分!!
- 简单的sql语句
- 调试程序过程中如何一次看到所有变量的值,请各位多多指教?
- 怎么样在gif图片里加上主页链接?
- delphi6在win2000server下的问题!
- 请问谁做过酒店管理系统?
- 关于按钮的问题
- 请教,dbGridEh,如何只在list 中修改,而不提交到数据库中去?
上面這幾個都是API函數來的,
findresource是在一個指定的句柄中查詢一個查詢的資源,本例中為ICO,即圖標資料
關於以上函數的詳細說明,樓主可以看API幫助如果樓主要保存的話,可以直接調用Ficon.SaveToFile
如果要保存imagelist1中所有的圖標,可以調用GetIcon,然後再用Icon的SavetoFile的方法
procedure TForm1.Save1Click(Sender: TObject);
var
i: integer;
SavePath: string;
begin
if Imagelist1.Count=0 then
begin
Application.MessageBox('请解出图标!',
'消息框',
MB_OK + MB_DEFBUTTON1 + MB_ICONINFORMATION);
Exit;
end;
SelectDirectory('请选择保存路径:','我的电脑',SavePath);
if SavePath <> '' then
begin
if SavePath[Length(SavePath)] = '\' then
SavePath := Copy(SavePath,1,Length(SavePath)-1);
fIcon := TIcon.Create;
for i := 0 to Imagelist1.Count - 1 do
begin
imagelist1.GetIcon(i,icon);
fIcon.SaveToFile(SavePath + '\' + IntToStr(i + 1) + '.ico');(到此出错:icon image is not valid)
fIcon.ReleaseHandle;
end;
fIcon.Free;
end;
end;
帮忙一下,好结帖了.