本例運行結果:Clsid: {557CF400-1A04-11D3-9A73-0000F81EF32E}
代碼文件:
FormatID: {B96B3CAB-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in BMP Codec
DllName:
FormatDescription: BMP
FilenameExtension: *.BMP;*.DIB;*.RLE
MimeType: image/bmp
Flags: 65543
Version: 1
SigCount: 1
SigSize: 2
Clsid: {557CF401-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CAE-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in JPEG Codec
DllName:
FormatDescription: JPEG
FilenameExtension: *.JPG;*.JPEG;*.JPE;*.JFIF
MimeType: image/jpeg
Flags: 65543
Version: 1
SigCount: 1
SigSize: 2
Clsid: {557CF402-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CB0-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in GIF Codec
DllName:
FormatDescription: GIF
FilenameExtension: *.GIF
MimeType: image/gif
Flags: 65543
Version: 1
SigCount: 2
SigSize: 6
Clsid: {557CF405-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CB1-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in TIFF Codec
DllName:
FormatDescription: TIFF
FilenameExtension: *.TIF;*.TIFF
MimeType: image/tiff
Flags: 65543
Version: 1
SigCount: 2
SigSize: 2
Clsid: {557CF406-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CAF-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in PNG Codec
DllName:
FormatDescription: PNG
FilenameExtension: *.PNG
MimeType: image/png
Flags: 65543
Version: 1
SigCount: 1
SigSize: 8unit Unit1;
窗體文件:
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses GDIPOBJ, GDIPAPI;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Align := alLeft;
Memo1.ScrollBars := ssBoth;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
num, size: Cardinal;
ImageCodecInfo: PImageCodecInfo;
i: Integer;
type
ArrImgCodInfo = array of TImageCodecInfo;
begin
GetImageEncodersSize(num, size);
GetMem(ImageCodecInfo, size);
GetImageEncoders(num, size, ImageCodecInfo);
Memo1.Clear;
for i := 0 to num - 1 do with Memo1.Lines do
begin
Add(format('Clsid: %s',[GUIDToString(ArrImgCodInfo(ImageCodecInfo)[i].Clsid)]));
Add(format('FormatID: %s',[GUIDToString(ArrImgCodInfo(ImageCodecInfo)[i].FormatID)]));
Add(format('CodecName: %s',[ArrImgCodInfo(ImageCodecInfo)[i].CodecName]));
Add(format('DllName: %s',[ArrImgCodInfo(ImageCodecInfo)[i].DllName]));
Add(format('FormatDescription: %s',[ArrImgCodInfo(ImageCodecInfo)[i].FormatDescription]));
Add(format('FilenameExtension: %s',[ArrImgCodInfo(ImageCodecInfo)[i].FilenameExtension]));
Add(format('MimeType: %s',[ArrImgCodInfo(ImageCodecInfo)[i].MimeType]));
Add(format('Flags: %d',[ArrImgCodInfo(ImageCodecInfo)[i].Flags]));
Add(format('Version: %d',[ArrImgCodInfo(ImageCodecInfo)[i].Version]));
Add(format('SigCount: %d',[ArrImgCodInfo(ImageCodecInfo)[i].SigCount]));
Add(format('SigSize: %d',[ArrImgCodInfo(ImageCodecInfo)[i].SigSize]));
Add('');
end;
FreeMem(ImageCodecInfo);
end;
end.object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClIEntHeight = 206
ClIEntWidth = 445
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Memo1: TMemo
Left = 8
Top = 8
Width = 337
Height = 145
Lines.Strings = (
'Memo1')
TabOrder = 0
end
object Button1: TButton
Left = 351
Top = 32
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
end
Clsid //獲取或設置 Guid 結構,其中包含能識別特定編碼解碼器的 GUID。
FormatID //獲取或設置 Guid 結構,其中包含用於識別編碼解碼器格式的 GUID。
CodecName //獲取或設置包含編碼解碼器名稱的字符串。
DllName //獲取或設置包含存放編碼解碼器的 DLL 的路徑名字符串。如果編碼解碼器不在 DLL 中,則該指針為空。
FormatDescription //獲取或設置描述編碼解碼器的文件格式的字符串。
FilenameExtension //獲取或設置包含編碼解碼器中使用的文件擴展名的字符串。這些擴展名用分號分隔。
MimeType //獲取或設置包含編碼解碼器的多用途網際郵件擴充協議 (MIME) 類型的字符串。
Flags //獲取或設置用於存儲有關編碼解碼器的其他信息的 32 位值。該屬性從 ImageCodecFlags 枚舉返回若干標志的組合。
Version //獲取或設置編碼解碼器的版本號。
SigMask //獲取或設置可用作篩選器的二維字節數組。
SigPattern //獲取或設置表示編碼解碼器簽名的二維字節數組。