ShGetFileInfo 来分别取得程序的大小图标
2006-04-18 17:47
375 查看
利用了 shellapi 中的 TShFileInfo 以及 ShGetFileInfo 来分别取得程序的大小图标
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses shellapi;
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
shFileInfo:TShFileInfo;
icon:Ticon;
begin
icon := ticon.Create;
try
if opendialog1.Execute then
begin
shGetFileInfo(pchar(opendialog1.FileName),0,shFileInfo,sizeof(TShFileInfo),
shellapi.SHGFI_ICON or shellapi.SHGFI_LARGEICON or shellapi.SHGFI_TYPENAME
or SHGFI_DISPLAYNAME );
icon.Handle := shFileInfo.hIcon;
self.Image1.Picture.Assign(icon);
form1.Caption:=shFileInfo.szDisplayName;
edit1.Text:=shFileinfo.szTypeName;
self.Image1.Update;
end;
finally
icon.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
shFileInfo:TShFileInfo;
icon:Ticon;
begin
icon := ticon.Create;
try
if opendialog1.Execute then
begin
shGetFileInfo(pchar(opendialog1.FileName),0,shFileInfo,sizeof(TShFileInfo),
shellapi.SHGFI_ICON or shellapi.SHGFI_SMALLICON or shellapi.SHGFI_TYPENAME);
icon.Handle := shFileInfo.hIcon;
self.Image1.Picture.Assign(icon);
self.Image1.Update;
end;
finally
icon.Free;
end;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses shellapi;
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
shFileInfo:TShFileInfo;
icon:Ticon;
begin
icon := ticon.Create;
try
if opendialog1.Execute then
begin
shGetFileInfo(pchar(opendialog1.FileName),0,shFileInfo,sizeof(TShFileInfo),
shellapi.SHGFI_ICON or shellapi.SHGFI_LARGEICON or shellapi.SHGFI_TYPENAME
or SHGFI_DISPLAYNAME );
icon.Handle := shFileInfo.hIcon;
self.Image1.Picture.Assign(icon);
form1.Caption:=shFileInfo.szDisplayName;
edit1.Text:=shFileinfo.szTypeName;
self.Image1.Update;
end;
finally
icon.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
shFileInfo:TShFileInfo;
icon:Ticon;
begin
icon := ticon.Create;
try
if opendialog1.Execute then
begin
shGetFileInfo(pchar(opendialog1.FileName),0,shFileInfo,sizeof(TShFileInfo),
shellapi.SHGFI_ICON or shellapi.SHGFI_SMALLICON or shellapi.SHGFI_TYPENAME);
icon.Handle := shFileInfo.hIcon;
self.Image1.Picture.Assign(icon);
self.Image1.Update;
end;
finally
icon.Free;
end;
end;
end.
相关文章推荐
- CodeProject - 在C#使用SHGetFileInfo获取(管理)文件或者文件夹图标(C#封装Win32函数的一个例子)
- SHGetFileInfo 获得文件类型图标
- SHGetFileInfo获取系统图标注意事项
- 使用SHGetFileInfo函数获取任何文件大图标
- SHGetFileInfo 获得文件类型图标
- 收藏——在C#使用SHGetFileInfo获取(管理)文件或者文件夹图标(C#封装Win32函数的一个例子)
- 【MoreWindows工作笔记4】 获取文件图标,类型名称,属性 SHGetFileInfo
- CodeProject - 在C#使用SHGetFileInfo获取(管理)文件或者文件夹图标(C#封装Win32函数的一个例子)
- SHGetFileInfo获取图标说明
- SHGetFileInfo 在WINCE下获得系统图标列表
- 获取文件图标,类型名称,属性 SHGetFileInfo
- SHGetFileInfo 显示文件类型图标
- 获取给定路径的图标,演示SHGetFileInfo用法
- C#获取文件(磁盘驱动器)的关联图标(使用API SHGetFileInfo)
- FileInfo 0.0.0005--masm32写的获取文件属性、版本、时间、MD5、SHA1 等信息的小程序
- Android程序开发所用app图标的几种大小
- SHGetFileInfo的用法
- Android之使用PackageManager取得程序的包名、图标等
- Obtaining (and managing) file and folder icons using SHGetFileInfo in C#
- SHGetFileInfo函数详解