用Delphi列出程序中的各种资源

时间:2010-02-05 17:12:33  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:sages, SysConst, ImgList;typeTForm1 = class(TForm)OpenDialog1: TOpenDialog;MainMenu1: TMainMenu;File1: TMenuItem;Open1: TMenuItem;Sve1: TMenuItem;treeRes: TTreeView;Splitter1: TSplitter;Panel1: TPanel;ilResources: TImageList;procedure Open1Click(Sender: TObject);privateXFile...
  正文:

unit frmMain;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, Menus, unitResourceDetails, unitPEFile,
unitResourceGraphics, unitResourceMessages, SysConst, ImgList;

type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
MainMenu1: TMainMenu;
File1: TMenuItem;
Open1: TMenuItem;
Sve1: TMenuItem;
treeRes: TTreeView;
Splitter1: TSplitter;
Panel1: TPanel;
ilResources: TImageList;
procedure Open1Click(Sender: TObject);
private
XFileName :string;
public
fModule : TResourceModule;
procedure OpenFile(AFileName:string);
procedure UpdateDisplay;
end;

var
Form1: TForm1;

const
RT_XPMANIFEST = MakeIntResource (24);
otDOSHeader = 1;
otCOFFHeader = 2;
otOptionalHeader = 3;
otSections = 4;

imgClosedFolder = 10;
imgOpenFolder = 11;
rstColors = '%d colours';
rstHighColor = 'High Colour';
rstTrueColor = 'True Colour';
rstLanguageNeutral = 'Language Neutral';
rstDuplicateResourceName = 'Duplicate Resource Name';
rstAnyFileFilter = 'Any File (*.*)|*.*';

rstChangeResourceProperties = 'change resource properties';

function GetTypeName (const tp : string) : string;
function GetTypeImage (const tp : string) : Integer;

implementation

{$R *.dfm}

function GetTypeImage (const tp : string) : Integer;
var
i : Integer;
begin
  Result := 0;
  i := ResourceNametoInt (tp);
 
  case i of
  Integer (RT_VERSION) : i := 8;
  Integer (RT_MESSAGETABLE) : i := Integer (RT_STRING)
end;

if (i >= 0) and (i < 10) then
Result := i
else
if tp = 'MIDI' then
Result := 12
else
if tp = 'WAVE' then
Result := 13
end;

function GetTypeName (const tp : string) : string;
var
i : Integer;
begin
  i := ResourceNameToInt (tp);
 
  case i of
  Integer (RT_BITMAP)        : result := 'Bitmap';
  Integer (RT_ICON)          : result := 'Icon';
  Integer (RT_CURSOR)        : result := 'Cursor';
  Integer (RT_MENU)          : result := 'Menu';
  Integer (RT_DIALOG)        : result := 'Dialog';
  Integer (RT_STRING)        : result := 'String';
  Integer (RT_ACCELERATOR)   : Result := 'Accelerator';
  Integer (RT_RCDATA)        : result := 'RCData';
  Integer (RT_MESSAGETABLE) : result := 'MessageTable';
  Integer (RT_VERSION)       : result := 'Version';
  Integer (RT_GROUP_CURSOR) : result := 'GroupCursor';
  Integer (RT_GROUP_ICON)    : result := 'GroupIcon';
  Integer (RT_XPMANIFEST)    : result := 'XPManifest';
  else
  result := tp
end
end;

procedure TForm1.Open1Click(Sender: TObject);
begin
  if OpenDialog1.Execute() then
  begin
    XFileName := OpenDialog1.FileName;
    OpenFile(XFileName);
  end; 
end;

procedure TForm1.OpenFile(AFileName: string);
begin
  if fModule <> nil then
  FreeAndNil(fModule);
  fModule := TPEResourceModule.Create;
  fModule.LoadFromFile (AFileName);
  UpdateDisplay;
end;

procedure TForm1.UpdateDisplay;
var
i : Integer;
rootNode, sectionNode : TTreeNode;
section : TImageSection;
"用Delphi列出程序中的各种资源"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/12794.html

 1/4    1 2 3 4 下一页 尾页


关键字:

关于《用Delphi列出程序中的各种资源》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td