see.....
ExtractIcon or ExtractIconEx or ExtractAssociatedIcon
DrawIcon or DrawIconEx
这方面的例子好多,搜一下先~~
........
ExtractIcon or ExtractIconEx or ExtractAssociatedIcon
DrawIcon or DrawIconEx
这方面的例子好多,搜一下先~~
........
解决方案 »
- Delphi图片显示问题
- 建立临时表后的问题之二
- 请教高手一个问题,在执行一个文件时,出现如下错误信息,undeclared identifier:'customersearchform',应该怎么办,谢谢!在线等待,非
- 在DBgrid中查找记录
- 请问98下的winipcfg.exe这个软件的功能是怎么实现的
- 如何在delphi程序中使用西班牙语?
- 这个问题十万火急啊~~~~~~~~~~请高手务必进来看看!!!一定给分
- 关于在表中设主键的问题
- 怎样将TDecisionQuery结果保存到文件?
- 我这两天是不是见鬼了!!!高手帮忙,分析原因。
- delphi的计算字段怎么用?
- 这个SQL怎么不能编辑呢?请教各位,小弟谢谢在先!!!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses
Registry, ShellApi;function StrLeft(const mStr: string; mDelimiter: string): string;
begin
Result := Copy(mStr, 1, Pos(mDelimiter, mStr) - 1);
end; { StrLeft }function StrRight(const mStr: string; mDelimiter: string): string;
begin
if Pos(mDelimiter, mStr) <= 0 then
Result := ''
else Result := Copy(mStr, Pos(mDelimiter, mStr) + Length(mDelimiter), MaxInt);
end; { StrRight }function FileIcon(mFileName: TFileName): THandle; { 返回文件的图标 }
var
vRegistry: TRegistry;
vExtension, vIconFileName: TFileName;
vIconIndex: Integer;
vExtDescription: string;
var
vBuffer: array[0 .. MAX_PATH] of Char;
vSysPath: string;
begin
Result := 0;
if not FileExists(mFileName) then Exit; GetSystemDirectory(vBuffer, MAX_PATH + 1);
vSysPath := string(vBuffer) + '\'; vRegistry := TRegistry.Create;
try
vExtension := UpperCase(ExtractFileExt(mFilename));
if (vExtension = '.EXE') or (vExtension = '.ICO') then begin
vIconFileName := mFilename;
vIconIndex := 0;
end else begin
vRegistry.RootKey := HKEY_CLASSES_ROOT;
if vRegistry.OpenKey(vExtension, False) then begin
vExtDescription := vRegistry.ReadString('');
vRegistry.OpenKey('\' + vExtDescription, False);
vRegistry.OpenKey('DefaultIcon', False);
vIconFileName := vRegistry.ReadString('');
vIconIndex := StrToIntDef(StrRight(vIconFileName, ','), 0);
vIconFileName := StrLeft(vIconFileName, ',');
end else begin
vIconFileName := vSysPath + 'Shell32.dll';
vIconIndex := 0;
end;
end;
Result := ExtractIcon(HInstance, PChar(vIconFileName), UINT(vIconIndex));
finally
vRegistry.Free;
end;
end; { FileIcon }procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
Image1.Picture.Icon.Handle := FileIcon(OpenDialog1.FileName);
end;end.