Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在delphi中保存提取的图标_Delphi_Save_Icons - Fatal编程技术网

如何在delphi中保存提取的图标

如何在delphi中保存提取的图标,delphi,save,icons,Delphi,Save,Icons,我正在尝试制作图标提取器 我成功地将图标添加到image1.picture.icon,其外观与原始文件图标相同, 但是当我试图保存时(iamge1.picture.icon.savetofile(c:\imahe.ico)) 它不是像现在这样省钱,它省钱的时候少了点颜色,而且看起来很丑 谁能告诉我我做错了什么吗 这是我的密码 procedure TForm1.Button1Click(Sender: TObject); begin OpenDialog1.Filter:='All file

我正在尝试制作图标提取器

我成功地将图标添加到image1.picture.icon,其外观与原始文件图标相同, 但是当我试图保存时(iamge1.picture.icon.savetofile(c:\imahe.ico))

它不是像现在这样省钱,它省钱的时候少了点颜色,而且看起来很丑

谁能告诉我我做错了什么吗

这是我的密码

procedure TForm1.Button1Click(Sender: TObject); 
begin 
 OpenDialog1.Filter:='All files |*.*'; 
 OpenDialog1.Title:='Please select file'; 
 if OpenDialog1.Execute then 
 Edit1.Text:=OpenDialog1.FileName; 
end;

procedure TForm1.Button3Click(Sender: TObject); 
var   
szFileName: string;   
Icon:       TIcon;   
SHInfo: TSHFileInfo; 
begin

  szFileName := Edit1.Text;
  if FileExists(Edit1.Text) then   
  begin
      Icon := TIcon.Create;
      SHGetFileInfo(PChar(szFileName), 0, SHInfo, SizeOf(SHInfo), SHGFI_ICON);
      Icon.Handle := SHInfo.hIcon;
      Image1.Picture.Icon := Icon;
      end;  
end;

procedure TForm1.Button2Click(Sender: TObject);  
begin  
  if SaveDialog1.Execute then  
   begin   
   Image1.Picture.Icon.SaveToFile(SaveDialog1.FileName+'.ico'); 
   ShowMessage('done');  
   end;  
end;
该函数具有多个标志以获得不同的图标大小

const
  SHIL_LARGE     = $00;  //The image size is normally 32x32 pixels. However, if the Use large icons option is selected from the Effects section of the Appearance tab in Display Properties, the image is 48x48 pixels.
  SHIL_SMALL     = $01;  //These images are the Shell standard small icon size of 16x16, but the size can be customized by the user.
  SHIL_EXTRALARGE= $02;  //These images are the Shell standard extra-large icon size. This is typically 48x48, but the size can be customized by the user.
  SHIL_SYSSMALL  = $03;  //These images are the size specified by GetSystemMetrics called with SM_CXSMICON and GetSystemMetrics called with SM_CYSMICON.
  SHIL_JUMBO     = $04;  //Windows Vista and later. The image is normally 256x256 pixels.
您可以这样使用此标志

SHGetFileInfo(PChar(szFileName), 0, SHInfo, SizeOf(SHInfo), SHGFI_ICON OR  SHIL_LARGE );
有关更多信息,请查看此问题的答案

该函数具有多个标志以获得不同的图标大小

const
  SHIL_LARGE     = $00;  //The image size is normally 32x32 pixels. However, if the Use large icons option is selected from the Effects section of the Appearance tab in Display Properties, the image is 48x48 pixels.
  SHIL_SMALL     = $01;  //These images are the Shell standard small icon size of 16x16, but the size can be customized by the user.
  SHIL_EXTRALARGE= $02;  //These images are the Shell standard extra-large icon size. This is typically 48x48, but the size can be customized by the user.
  SHIL_SYSSMALL  = $03;  //These images are the size specified by GetSystemMetrics called with SM_CXSMICON and GetSystemMetrics called with SM_CYSMICON.
  SHIL_JUMBO     = $04;  //Windows Vista and later. The image is normally 256x256 pixels.
您可以这样使用此标志

SHGetFileInfo(PChar(szFileName), 0, SHInfo, SizeOf(SHInfo), SHGFI_ICON OR  SHIL_LARGE );
有关更多信息,请查看此问题的答案


我想知道为什么我这里的代码不适用于我,这是我如何使用过程TForm1.Button4Click(发送方:TObject);var hicon:TIcon;begin hicon:=TIcon.Create;尝试GetIconFromFile(Edit1.Text、hicon、SHIL_JUMBO);图像1.图片.图标.分配(hIcon)//最终分配给timage hIcon.免费;结束;结束;但是点击时什么也没发生:(@radick,你必须用这种方式使用标志
SHGetFileInfo(PChar(szFileName),0,SHInfo,SizeOf(SHInfo),SHGFI_图标或SHIL_LARGE);
再次感谢你的回复,但它仍然在我的计算机上保存了一些奇怪的图像:(但在我的申请表上看起来很漂亮:),但我不明白它为什么这样保存:(我想知道为什么这里的代码对我不起作用,这是我如何使用过程TForm1.Button4Click(Sender:TObject);var-hicon:TIcon;begin-hicon:=TIcon.Create;尝试GetIconFromFile(Edit1.Text,hicon,SHIL\JUMBO);Image1.Picture.Icon.Assign(hicon);//分配给timage finally hIcon.Free;end;end;但单击时不会发生任何事情:(@radick,您必须以这种方式使用标志
SHGetFileInfo(PChar(szFileName)、0、SHInfo、SizeOf(SHInfo)、SHGFI_图标或SHIL_LARGE);
再次感谢您的回复,但它仍然会在我的计算机上保存一些奇怪的图像:(但在我的申请表上,它看起来很漂亮:),但我不明白为什么它会这样保存:(