delphi 获取指定文件的图标
前段时间因为项目需要,获取指定文件的图标,绕了很多弯子,现在弄出来了,跟大家共享下.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShellAPI, ExtCtrls;
type
TForm1 = class(TForm)
lbl1: TLabel;
btn1: TButton;
dlgOpen1: TOpenDialog;
imgPic: TImage;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Mem : TMemoryStream;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
FileInfo : TSHFileInfo;
hc: TIcon;
Bitmap : TBitmap;
begin
Mem := Tmemorystream.Create;
if dlgOpen1.Execute then
begin
FileInfo.iIcon := 0;
SHGetFileInfo(pchar(dlgOpen1.filename), 0, FileInfo, SizeOf(TSHFileInfo),
SHGFI_ICON or SHGFI_LARGEICON);
imgPic.Picture.Icon.Handle := FileInfo.hIcon;
hc := TIcon.Create;
Bitmap := TBitmap.Create;
hc.Handle := FileInfo.hIcon;
Bitmap.width := hc.width;
Bitmap.height := hc.height;
Bitmap.Canvas.Draw(0, 0, hc);
Bitmap.SaveToStream(Mem);
Mem.SaveToFile(ExtractFilePath(paramstr(0)) + 'qinxh.bmp');
imgPic.Picture.LoadfromFile(ExtractFilePath(paramstr(0)) + 'qinxh.bmp');
hc.Free;
Bitmap.Free;
end;
end;
end.
相关文档:
unit winntService;
interface
uses
Windows,WinSvc,WinSvcEx;
function InstallService(const strServiceName,strDisplayName,strDescription,strFilename: string):Boolean;
procedure UninstallService(strServiceName:string);
implementation
function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: C ......
虽然用盗版是件很不光彩的事情,但是这个软件目前实在是买不起.呵,折磨了数月,而今天却不经意间成功了. 实在是难掩心中快感.
这所谓的破解过程相当简单
百度搜索一下
Delphi.Distiller.v1.85
解压后运行,点到DELPHI2010页面,>Tweat>再勾上Remove Delphi 2010 Updata....,再点击Clear All Embarcadero...
接着就OK ......
Source Code
http://www.codefans.com/CodeList/Catalog_5_CodeTime_Desc_1.html
http://www.vscodes.com/sitemap.html
http://www.itlove.net/Soft/261/
DelphiX
http://www.micrel.cz/Dx/
http://www.delphi3d.net/index.php
http://www.pascalgamedevelopment.com/
http://www.2ccc.com/article.asp?articleid ......
引用参数:
引用参数用var关键字标示
procedure DoubleTheValue (var Value: Integer);
begin
Value := Value * 2;
end;
在这种情况下,参数既把一个值传递给过程,又把新值返回给调用过程的代码。当你执行完以下代码时:
var
X: Integer;
begin
X := 10;
DoubleTheValue (X);
x变量的值变成了20 ......
Delphi 数据类型列表
分类
范围
字节
备注
简单类型
序数
整数
Integer
-2147483648 .. 2147483647
4
有符号32位
Cardinal
0 .. 4294967295
4
无符号32位
Shortint
-128 .. 127
1
有符号8位
Smallint
-32768 .. 32767
2
有符号16位
Longint
-2147483648 .. 2147483647
4
有符号32位
Int64
- ......