进程高手!如何得某个进程的一些详细信息,如占内存大小、包括的dll文件等??在线等(200分)

  • 主题发起人 主题发起人 dzy983
  • 开始时间 开始时间
D

dzy983

Unregistered / Unconfirmed
GUEST, unregistred user!
操作系统2000,<br>问题1:我得到当前所有进程中,代码如下:<br>var<br>&nbsp; &nbsp; handles:Thandle; &nbsp;//进程名柄<br>&nbsp; &nbsp; ppro:TProcessEntry32; //进程记录结构<br>&nbsp; &nbsp; //ppro1:Tmoduleentry32;<br>&nbsp; &nbsp; bl:bool;<br>&nbsp; &nbsp; ls_Str:string;<br>begin<br>&nbsp; &nbsp;handles:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br>&nbsp; &nbsp; //new(ppro);<br>&nbsp; &nbsp; ppro.dwsize:=sizeof(Tprocessentry32);<br>&nbsp; &nbsp; //ppro1.dwSize :=sizeof(Tmoduleentry32);<br>&nbsp; &nbsp; bl:= process32first(handles,ppro);<br>&nbsp; &nbsp; while bl do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; //if module32first(handles,ppro1) then ls_str:=ppro1.szExePath ;<br>&nbsp; &nbsp; &nbsp; &nbsp; with listview1.items.add do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;caption:=(ppro.szexefile);// ls_str;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;subitems.add(inttostr(ppro.pcPriClassBase));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;subitems.add(inttostr(ppro.th32ProcessID));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; bl:=process32next(handles,ppro);<br>&nbsp; &nbsp; &nbsp; end;<br>end;<br><br>&nbsp;但是ppro.szexefile得到进程文件名中没有包括路径。<br><br>问题2:<br>&nbsp; 当知道某一进程后如何得到该进程的所有模块,也就是它包括的所有dll文件及每个dll文件的基地址、占内存大小、入口地址。<br><br>问题3:<br>&nbsp; 当知道某一进程后如何得到该进程的优先级别、占内存大小以及此进程的版本信息(公司名称等)、内存信息(页面地址、类型、映射文件等)。<br>进程高手指教,最好给出源代码或例子。分不够再加!在线等待!!!高手帮助!<br>
 
难道大富翁里都没人知道吗?哎!
 
哎,没想到大富翁里也没人知道啊!没办法啦!
 
到delphi5程序员指南中去找例程
 
{==============================================================================|<br>| Project : PE Viewer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;000.005.000 |<br>|==============================================================================|<br>| Content: &nbsp;PE resources classes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br>|==============================================================================|<br>| The contents of this file are subject to the Mozilla Public License Ver. 1.0 |<br>| (the "License"); you may not use this file except in compliance with the &nbsp; &nbsp; |<br>| License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ |<br>| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br>| Software distributed under the License is distributed on an "AS IS" basis, &nbsp; |<br>| WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for |<br>| the specific language governing rights and limitations under the License. &nbsp; &nbsp;|<br>|==============================================================================|<br>| The Original Code is Petr Vones. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br>|==============================================================================|<br>| The Initial Developer of the Original Code is Petr Vones, petr.v@mujmail.cz &nbsp;|<br>| Portions created by Petr Vones are Copyright (C) 2000. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br>| All Rights Reserved. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br>|==============================================================================|<br>| Contributor(s): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br>|==============================================================================}<br><br>unit PeResource;<br><br>{$I JCL.INC}<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, Classes, SysUtils, Graphics, ComCtrls,<br>&nbsp; {$IFDEF DELPHI5_UP}<br>&nbsp; Contnrs,<br>&nbsp; {$ENDIF}<br>&nbsp; JclBase, JclFileUtils, JclPeImage, JclStrings;<br><br>type<br>&nbsp; PAccelTableEntry = ^TAccelTableEntry;<br>&nbsp; ACCELTABLEENTRY = packed record<br>&nbsp; &nbsp; fFlags: Word;<br>&nbsp; &nbsp; wAnsi: Word;<br>&nbsp; &nbsp; wId: Word;<br>&nbsp; &nbsp; padding: Word;<br>&nbsp; end; &nbsp;<br>&nbsp; {$EXTERNALSYM ACCELTABLEENTRY}<br>&nbsp; TAccelTableEntry = ACCELTABLEENTRY;<br><br>&nbsp; PCursorDir = ^TCursorDir;<br>&nbsp; CURSORDIR = packed record<br>&nbsp; &nbsp; Width: Word;<br>&nbsp; &nbsp; Height: Word;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM CURSORDIR}<br>&nbsp; TCursorDir = CURSORDIR;<br><br>&nbsp; PCursorShape = ^TCursorShape;<br>&nbsp; _CURSORSHAPE = packed record<br>&nbsp; &nbsp; xHotSpot: Integer;<br>&nbsp; &nbsp; yHotSpot: Integer;<br>&nbsp; &nbsp; cx: Integer;<br>&nbsp; &nbsp; cy: Integer;<br>&nbsp; &nbsp; cbWidth: Integer;<br>&nbsp; &nbsp; Planes: Byte;<br>&nbsp; &nbsp; BitsPixel: Byte;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM _CURSORSHAPE}<br>&nbsp; TCursorShape = _CURSORSHAPE;<br>&nbsp; CURSORSHAPE = _CURSORSHAPE;<br>&nbsp; {$EXTERNALSYM CURSORSHAPE}<br><br>&nbsp; PLocalHeader = ^TLocalHeader;<br>&nbsp; _LOCALHEADER = packed record<br>&nbsp; &nbsp; xHotSpot: Word;<br>&nbsp; &nbsp; yHotSpot: Word;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM _LOCALHEADER}<br>&nbsp; TLocalHeader = _LOCALHEADER;<br>&nbsp; LOCALHEADER = _LOCALHEADER;<br>&nbsp; {$EXTERNALSYM LOCALHEADER}<br><br>&nbsp; PNewHeader = ^TNewHeader;<br>&nbsp; _NEWHEADER = packed record<br>&nbsp; &nbsp; Reserved: Word;<br>&nbsp; &nbsp; ResType: Word;<br>&nbsp; &nbsp; ResCount: Word;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM _NEWHEADER}<br>&nbsp; TNewHeader = _NEWHEADER;<br>&nbsp; NEWHEADER = _NEWHEADER;<br>&nbsp; {$EXTERNALSYM NEWHEADER}<br><br>&nbsp; PIconResdir = ^TIconResdir;<br>&nbsp; ICONRESDIR = packed record<br>&nbsp; &nbsp; Width: Byte;<br>&nbsp; &nbsp; Height: Byte;<br>&nbsp; &nbsp; ColorCount: Byte;<br>&nbsp; &nbsp; Reserved: Byte;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM ICONRESDIR}<br>&nbsp; TIconResdir = ICONRESDIR;<br><br>&nbsp; TResInfo = packed record<br>&nbsp; &nbsp; case Integer of<br>&nbsp; &nbsp; &nbsp; 0: (Icon: TIconResdir);<br>&nbsp; &nbsp; &nbsp; 1: (Cursor: TCursorDir);<br>&nbsp; end;<br>&nbsp; {$NODEFINE TResInfo}<br><br>&nbsp; PResDir = ^TResDir;<br>&nbsp; _RESDIR = packed record<br>&nbsp; &nbsp; ResInfo: TResInfo;<br>&nbsp; &nbsp; Planes: Word;<br>&nbsp; &nbsp; BitCount: Word;<br>&nbsp; &nbsp; BytesInRes: DWORD;<br>&nbsp; &nbsp; IconCursorId: Word;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM _RESDIR}<br>&nbsp; TResDir = _RESDIR;<br>&nbsp; RESDIR = _RESDIR;<br>&nbsp; {$EXTERNALSYM RESDIR}<br><br>&nbsp; PDlgTemplate = ^TDlgTemplate;<br>&nbsp; DLGTEMPLATE = packed record<br>&nbsp; &nbsp; style: DWORD;<br>&nbsp; &nbsp; dwExtendedStyle: DWORD;<br>&nbsp; &nbsp; cdit: Word;<br>&nbsp; &nbsp; x: ShortInt; // short<br>&nbsp; &nbsp; y: ShortInt;<br>&nbsp; &nbsp; cx: ShortInt;<br>&nbsp; &nbsp; cy: ShortInt;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM DLGTEMPLATE}<br>&nbsp; TDlgTemplate = DLGTEMPLATE;<br><br>&nbsp; PDlgItemTemplate = ^TDlgItemTemplate;<br>&nbsp; DLGITEMTEMPLATE = packed record<br>&nbsp; &nbsp; style: DWORD;<br>&nbsp; &nbsp; dwExtendedStyle: DWORD;<br>&nbsp; &nbsp; x: ShortInt;<br>&nbsp; &nbsp; y: ShortInt;<br>&nbsp; &nbsp; cx: ShortInt;<br>&nbsp; &nbsp; cy: ShortInt;<br>&nbsp; &nbsp; id: Word;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM DLGITEMTEMPLATE}<br>&nbsp; TDlgItemTemplate = DLGITEMTEMPLATE;<br><br>&nbsp; PMenuHeader = ^TMenuHeader;<br>&nbsp; MENUHEADER = packed record<br>&nbsp; &nbsp; wVersion: Word;<br>&nbsp; &nbsp; cbHeaderSize: Word;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM MENUHEADER}<br>&nbsp; TMenuHeader = MENUHEADER;<br><br>&nbsp; PMenuHelpID = ^TMenuHelpID;<br>&nbsp; MENUHELPID = packed record<br>&nbsp; &nbsp; helpID: DWORD;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM MENUHELPID}<br>&nbsp; TMenuHelpID = MENUHELPID;<br><br>&nbsp; PNormalMenuItem = ^TNormalMenuItem;<br>&nbsp; NORMALMENUITEM = packed record<br>&nbsp; &nbsp; resInfo: WORD;<br>&nbsp; &nbsp; menuText: Pointer; // szOrOrd<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM NORMALMENUITEM}<br>&nbsp; TNormalMenuItem = NORMALMENUITEM;<br><br>&nbsp; PPopupMenuItem = ^TPopupMenuItem;<br>&nbsp; POPUPMENUITEM = packed record<br>&nbsp; &nbsp; type_: DWORD;<br>&nbsp; &nbsp; state: DWORD;<br>&nbsp; &nbsp; id: DWORD;<br>&nbsp; &nbsp; resInfo: Word;<br>&nbsp; &nbsp; menuText: Pointer; // szOrOrd<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM POPUPMENUITEM}<br>&nbsp; TPopupMenuItem = POPUPMENUITEM;<br><br>&nbsp; PMenuExTemplateHeader = ^TMenuExTemplateHeader;<br>&nbsp; MENUEX_TEMPLATE_HEADER = packed record<br>&nbsp; &nbsp; wVersion: Word;<br>&nbsp; &nbsp; wOffset: Word;<br>&nbsp; &nbsp; dwHelpId: DWORD;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM MENUEX_TEMPLATE_HEADER}<br>&nbsp; TMenuExTemplateHeader = MENUEX_TEMPLATE_HEADER;<br><br>&nbsp; PMenuExTemplateItem = ^TMenuExTemplateItem;<br>&nbsp; MENUEX_TEMPLATE_ITEM = packed record<br>&nbsp; &nbsp; dwType: DWORD;<br>&nbsp; &nbsp; dwState: DWORD;<br>&nbsp; &nbsp; uId: UINT;<br>&nbsp; &nbsp; bResInfo: Word;<br>&nbsp; &nbsp; szText: array[0..0] of WideChar;<br>&nbsp; &nbsp; dwHelpId: DWORD;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM MENUEX_TEMPLATE_ITEM}<br>&nbsp; TMenuExTemplateItem = MENUEX_TEMPLATE_ITEM;<br><br>&nbsp; PMessageResourceBlock = ^TMessageResourceBlock;<br>&nbsp; _MESSAGE_RESOURCE_BLOCK = packed record<br>&nbsp; &nbsp; LowId: ULONG;<br>&nbsp; &nbsp; HighId: ULONG;<br>&nbsp; &nbsp; OffsetToEntries: ULONG;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM _MESSAGE_RESOURCE_BLOCK}<br>&nbsp; TMessageResourceBlock = _MESSAGE_RESOURCE_BLOCK;<br>&nbsp; MESSAGE_RESOURCE_BLOCK = _MESSAGE_RESOURCE_BLOCK;<br>&nbsp; {$EXTERNALSYM MESSAGE_RESOURCE_BLOCK}<br><br>&nbsp; PMessageResourceData = ^TMessageResourceData;<br>&nbsp; _MESSAGE_RESOURCE_DATA = packed record<br>&nbsp; &nbsp; NumberOfBlocks: ULONG;<br>&nbsp; &nbsp; // Blocks: array[0..0] of TMessageResourceBlock;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM _MESSAGE_RESOURCE_DATA}<br>&nbsp; TMessageResourceData = _MESSAGE_RESOURCE_DATA;<br>&nbsp; MESSAGE_RESOURCE_DATA = _MESSAGE_RESOURCE_DATA;<br>&nbsp; {$EXTERNALSYM MESSAGE_RESOURCE_DATA}<br><br>&nbsp; PMessageResourceEntry = ^TMessageResourceEntry;<br>&nbsp; _MESSAGE_RESOURCE_ENTRY = packed record<br>&nbsp; &nbsp; Length: Word;<br>&nbsp; &nbsp; Flags: Word;<br>&nbsp; &nbsp; // Text: array[0..0] of Char;<br>&nbsp; end;<br>&nbsp; {$EXTERNALSYM _MESSAGE_RESOURCE_ENTRY}<br>&nbsp; TMessageResourceEntry = _MESSAGE_RESOURCE_ENTRY;<br>&nbsp; MESSAGE_RESOURCE_ENTRY = _MESSAGE_RESOURCE_ENTRY;<br>&nbsp; {$EXTERNALSYM MESSAGE_RESOURCE_ENTRY}<br><br>(*<br><br>Value Meaning<br>0x0080 Button<br>0x0081 Edit<br>0x0082 Static<br>0x0083 List box<br>0x0084 Scroll bar<br>0x0085 Combo box}<br><br>&nbsp; PDlgTemplateEx = ^TDlgTemplateEx;<br>&nbsp; DLGTEMPLATEEX = packed record<br>&nbsp; &nbsp; dlgVer: WORD;<br>&nbsp; &nbsp; signature: WORD;<br>&nbsp; &nbsp; helpID: DWORD;<br>&nbsp; &nbsp; exStyle: DWORD;<br>&nbsp; &nbsp; style: DWORD;<br>&nbsp; &nbsp; cDlgItems: WORD;<br>&nbsp; &nbsp; x: short;<br>&nbsp; &nbsp; y: short;<br>&nbsp; &nbsp; cx: short;<br>&nbsp; &nbsp; cy: short;<br>&nbsp; &nbsp; sz_Or_Ord menu; &nbsp; &nbsp; &nbsp; &nbsp; // name or ordinal of a menu resource<br>&nbsp; &nbsp; sz_Or_Ord windowClass; &nbsp;// name or ordinal of a window class<br>&nbsp; &nbsp; WCHAR &nbsp;title[titleLen]; // title string of the dialog box<br>&nbsp; &nbsp; short &nbsp;pointsize; &nbsp; &nbsp; &nbsp; // if DS_SETFONT or DS_SHELLFONT is set<br>&nbsp; &nbsp; short &nbsp;weight; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// if DS_SETFONT or DS_SHELLFONT is set<br>&nbsp; &nbsp; short &nbsp;bItalic; &nbsp; &nbsp; &nbsp; &nbsp; // if DS_SETFONT or DS_SHELLFONT is set<br>&nbsp; &nbsp; WCHAR &nbsp;font[fontLen]; &nbsp; // if DS_SETFONT or DS_SHELLFONT is set<br>} DLGTEMPLATEEX;<br><br><br>&nbsp;typedef struct {<br>&nbsp; &nbsp; DWORD &nbsp;helpID;<br>&nbsp; &nbsp; DWORD &nbsp;exStyle;<br>&nbsp; &nbsp; DWORD &nbsp;style;<br>&nbsp; &nbsp; short &nbsp;x;<br>&nbsp; &nbsp; short &nbsp;y;<br>&nbsp; &nbsp; short &nbsp;cx;<br>&nbsp; &nbsp; short &nbsp;cy;<br>&nbsp; &nbsp; WORD &nbsp; id;<br>&nbsp; &nbsp; sz_Or_Ord windowClass; // name or ordinal of a window class<br>&nbsp; &nbsp; sz_Or_Ord title; &nbsp; &nbsp; &nbsp; // title string or ordinal of a resource<br>&nbsp; &nbsp; WORD &nbsp; extraCount; &nbsp; &nbsp; // bytes of following creation data<br>} DLGITEMTEMPLATEEX;<br><br>struct FONTDIRENTRY {<br>&nbsp; &nbsp; WORD dfVersion;<br>&nbsp; &nbsp; DWORD dfSize;<br>&nbsp; &nbsp; char dfCopyright[60];<br>&nbsp; &nbsp; WORD dfType;<br>&nbsp; &nbsp; WORD dfPoints;<br>&nbsp; &nbsp; WORD dfVertRes;<br>&nbsp; &nbsp; WORD dfHorizRes;<br>&nbsp; &nbsp; WORD dfAscent;<br>&nbsp; &nbsp; WORD dfInternalLeading;<br>&nbsp; &nbsp; WORD dfExternalLeading;<br>&nbsp; &nbsp; BYTE dfItalic;<br>&nbsp; &nbsp; BYTE dfUnderline;<br>&nbsp; &nbsp; BYTE dfStrikeOut;<br>&nbsp; &nbsp; WORD dfWeight;<br>&nbsp; &nbsp; BYTE dfCharSet;<br>&nbsp; &nbsp; WORD dfPixWidth;<br>&nbsp; &nbsp; WORD dfPixHeight;<br>&nbsp; &nbsp; BYTE dfPitchAndFamily;<br>&nbsp; &nbsp; WORD dfAvgWidth;<br>&nbsp; &nbsp; WORD dfMaxWidth;<br>&nbsp; &nbsp; BYTE dfFirstChar;<br>&nbsp; &nbsp; BYTE dfLastChar;<br>&nbsp; &nbsp; BYTE dfDefaultChar;<br>&nbsp; &nbsp; BYTE dfBreakChar;<br>&nbsp; &nbsp; WORD dfWidthBytes;<br>&nbsp; &nbsp; DWORD dfDevice;<br>&nbsp; &nbsp; DWORD dfFace;<br>&nbsp; &nbsp; DWORD dfReserved;<br>&nbsp; &nbsp; char szDeviceName[];<br>&nbsp; &nbsp; char szFaceName[];<br>};<br><br>struct FONTGROUPHDR {<br>&nbsp; &nbsp; WORD NumberOfFonts;<br>&nbsp; &nbsp; DIRENTRY &nbsp;DE [1];<br>};<br><br>*)<br><br>type<br>&nbsp; TPeResKind = (rkAccelerator, rkAvi, rkBitmap, rkCursor, rkData, rkDialog,<br>&nbsp; &nbsp; rkHTML, rkIcon, rkMenu, rkMessageTable, rkString, rkVersion, rkUnknown);<br><br>&nbsp; TPeResImage = class;<br><br>&nbsp; TPeResItem = class;<br><br>&nbsp; TPeResItem = class(TPersistent)<br>&nbsp; private<br>&nbsp; &nbsp; FKind: TPeResKind;<br>&nbsp; &nbsp; FList: TObjectList;<br>&nbsp; &nbsp; FResImage: TPeResImage;<br>&nbsp; &nbsp; FResourceItem: TJclPeResourceItem;<br>&nbsp; &nbsp; FStream: TJclPeResourceRawStream;<br>&nbsp; &nbsp; function GetItems(Index: Integer): TPeResItem;<br>&nbsp; &nbsp; function GetItemCount: Integer;<br>&nbsp; &nbsp; function GetStream: TJclPeResourceRawStream;<br>&nbsp; protected<br>&nbsp; &nbsp; procedure CreateList; virtual;<br>&nbsp; public<br>&nbsp; &nbsp; constructor Create(AResImage: TPeResImage; AResourceItem: TJclPeResourceItem); virtual;<br>&nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; &nbsp; function IsList: Boolean; virtual;<br>&nbsp; &nbsp; function Offset: Integer;<br>&nbsp; &nbsp; function RawData: Pointer;<br>&nbsp; &nbsp; function ResName: string; virtual;<br>&nbsp; &nbsp; function ResType: TJclPeResourceKind;<br>&nbsp; &nbsp; procedure SaveToStream(Stream: TStream); virtual;<br>&nbsp; &nbsp; function Size: Integer;<br>&nbsp; &nbsp; property ItemCount: Integer read GetItemCount;<br>&nbsp; &nbsp; property Items[Index: Integer]: TPeResItem read GetItems; default;<br>&nbsp; &nbsp; property Kind: TPeResKind read FKind;<br>&nbsp; &nbsp; property ResourceItem: TJclPeResourceItem read FResourceItem;<br>&nbsp; &nbsp; property Stream: TJclPeResourceRawStream read GetStream;<br>&nbsp; end;<br><br>&nbsp; TJclReResItemClass = class of TPeResItem;<br><br>&nbsp; TPeResUnknown = class(TPeResItem)<br>&nbsp; public<br>&nbsp; &nbsp; function FileExt: string; dynamic;<br>&nbsp; &nbsp; function IsList: Boolean; override;<br>&nbsp; &nbsp; function ResName: string; override;<br>&nbsp; end;<br><br>&nbsp; TPeGraphicProperties = record<br>&nbsp; &nbsp; Width, Height, BitsPerPixel: Integer;<br>&nbsp; end;<br><br>&nbsp; TPeResUnkGraphic = class(TPeResUnknown)<br>&nbsp; public<br>&nbsp; &nbsp; function GraphicProperties: TPeGraphicProperties; virtual; abstract;<br>&nbsp; end;<br><br>&nbsp; TPeResUnkStrings = class(TPeResUnknown)<br>&nbsp; protected<br>&nbsp; &nbsp; procedure AssignTo(Dest: TPersistent); override;<br>&nbsp; public<br>&nbsp; &nbsp; function FileExt: string; override;<br>&nbsp; &nbsp; procedure FillStrings(Strings: TStrings; StripCrLf: Boolean = False); virtual; abstract;<br>&nbsp; end;<br><br>&nbsp; TPeResAccelerator = class(TPeResUnkStrings)<br>&nbsp; public<br>&nbsp; &nbsp; procedure FillStrings(Strings: TStrings; StripCrLf: Boolean = False); override;<br>&nbsp; end;<br><br>&nbsp; TPeResAvi = class(TPeResUnknown)<br>&nbsp; protected<br>&nbsp; &nbsp; procedure AssignTo(Dest: TPersistent); override;<br>&nbsp; public<br>&nbsp; &nbsp; function FileExt: string; override;<br>&nbsp; end;<br><br>&nbsp; TPeResBitmap = class(TPeResUnkGraphic)<br>&nbsp; protected<br>&nbsp; &nbsp; procedure AssignTo(Dest: TPersistent); override;<br>&nbsp; public<br>&nbsp; &nbsp; function GraphicProperties: TPeGraphicProperties; override;<br>&nbsp; &nbsp; function FileExt: string; override;<br>&nbsp; &nbsp; procedure SaveToStream(Stream: TStream); override;<br>&nbsp; end;<br><br>&nbsp; TPeResCursorItem = class(TPeResUnkGraphic)<br>&nbsp; private<br>&nbsp; &nbsp; FResInfo: PResDir;<br>&nbsp; protected<br>&nbsp; &nbsp; procedure AssignTo(Dest: TPersistent); override;<br>&nbsp; public<br>&nbsp; &nbsp; function FileExt: string; override;<br>&nbsp; &nbsp; function GraphicProperties: TPeGraphicProperties; override;<br>&nbsp; &nbsp; function ResName: string; override;<br>&nbsp; &nbsp; procedure SaveToStream(Stream: TStream); override;<br>&nbsp; end;<br><br>&nbsp; TPeResCursor = class(TPeResUnknown)<br>&nbsp; private<br>&nbsp; &nbsp; function GetItems(Index: Integer): TPeResCursorItem;<br>&nbsp; protected<br>&nbsp; &nbsp; procedure CreateList; override;<br>&nbsp; public<br>&nbsp; &nbsp; function IsList: Boolean; override;<br>&nbsp; &nbsp; property Items[Index: Integer]: TPeResCursorItem read GetItems; default;<br>&nbsp; end;<br><br>&nbsp; TPeResDialog = class(TPeResUnknown)<br>&nbsp; public<br>&nbsp; &nbsp; function CanShowDialog: Boolean;<br>&nbsp; &nbsp; function ShowDialog(ParentWnd: HWND): Integer;<br>&nbsp; end;<br><br>&nbsp; TPeResDataKind = (dkUnknown, dkDFM, dkPackageDescription, dkPackageInfo);<br><br>&nbsp; TPeResRCData = class(TPeResUnknown)<br>&nbsp; private<br>&nbsp; &nbsp; FDataKind: TPeResDataKind;<br>&nbsp; protected<br>&nbsp; &nbsp; procedure AssignTo(Dest: TPersistent); override;<br>&nbsp; &nbsp; procedure CheckFormat;<br>&nbsp; &nbsp; procedure DFMToStrings(Strings: TStrings);<br>&nbsp; &nbsp; procedure PackageInfoToStrings(Strings: TStrings);<br>&nbsp; public<br>&nbsp; &nbsp; constructor Create(AResImage: TPeResImage; AResourceItem: TJclPeResourceItem); override;<br>&nbsp; &nbsp; function FileExt: string; override;<br>&nbsp; &nbsp; property DataKind: TPeResDataKind read FDataKind;<br>&nbsp; end;<br><br>&nbsp; TPeResHTML = class(TPeResUnknown)<br>&nbsp; public<br>&nbsp; &nbsp; function FileExt: string; override;<br>&nbsp; &nbsp; function ResPath: string;<br>&nbsp; end;<br><br>&nbsp; TPeResIconItem = class(TPeResCursorItem)<br>&nbsp; public<br>&nbsp; &nbsp; function FileExt: string; override;<br>&nbsp; &nbsp; function GraphicProperties: TPeGraphicProperties; override;<br>&nbsp; end;<br><br>&nbsp; TPeResIcon = class(TPeResCursor)<br>&nbsp; private<br>&nbsp; &nbsp; function GetItems(Index: Integer): TPeResIconItem;<br>&nbsp; public<br>&nbsp; &nbsp; property Items[Index: Integer]: TPeResIconItem read GetItems; default;<br>&nbsp; end;<br><br>&nbsp; TPeResMenu = class(TPeResUnknown)<br>&nbsp; end;<br><br>&nbsp; TPeMessageTable = class(TPeResUnkStrings)<br>&nbsp; public<br>&nbsp; &nbsp; procedure FillStrings(Strings: TStrings; StripCrLf: Boolean = False); override;<br>&nbsp; end;<br><br>&nbsp; TPeResString = class(TPeResUnkStrings)<br>&nbsp; public<br>&nbsp; &nbsp; procedure FillStrings(Strings: TStrings; StripCrLf: Boolean = False); override;<br>&nbsp; end;<br><br>&nbsp; TPeResVersion = class(TPeResUnkStrings)<br>&nbsp; public<br>&nbsp; &nbsp; procedure FillStrings(Strings: TStrings; StripCrLf: Boolean = False); override;<br>&nbsp; end;<br><br>&nbsp; TPeResImage = class(TObjectList)<br>&nbsp; private<br>&nbsp; &nbsp; FCursorEntry: TJclPeResourceList;<br>&nbsp; &nbsp; FIconEntry: TJclPeResourceList;<br>&nbsp; &nbsp; FImageAttached: Boolean;<br>&nbsp; &nbsp; FLibHandle: THandle;<br>&nbsp; &nbsp; FPeImage: TJclPeImage;<br>&nbsp; &nbsp; function GetFileName: TFileName;<br>&nbsp; &nbsp; procedure SetFileName(const Value: TFileName);<br>&nbsp; &nbsp; procedure SetPeImage(const Value: TJclPeImage);<br>&nbsp; &nbsp; function GetItems(Index: Integer): TPeResItem;<br>&nbsp; &nbsp; function GetLibHandle: THandle;<br>&nbsp; protected<br>&nbsp; &nbsp; procedure CreateList;<br>&nbsp; &nbsp; procedure UnloadLib;<br>&nbsp; public<br>&nbsp; &nbsp; constructor Create;<br>&nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; &nbsp; procedure Clear; override;<br>&nbsp; &nbsp; property ImageAttached: Boolean read FImageAttached;<br>&nbsp; &nbsp; property Items[Index: Integer]: TPeResItem read GetItems; default;<br>&nbsp; &nbsp; property LibHandle: THandle read GetLibHandle;<br>&nbsp; &nbsp; property FileName: TFileName read GetFileName write SetFileName;<br>&nbsp; &nbsp; property PeImage: TJclPeImage read FPeImage write SetPeImage;<br>&nbsp; end;<br><br>&nbsp; function LangNameFromName(const Name: string; ShortName: Boolean = False): string;<br><br>implementation<br><br>uses<br>&nbsp; Consts, JclLocales, JclSysUtils, JclWin32;<br><br>resourcestring<br>&nbsp; RsPeResAccelerator = 'Accel table';<br>&nbsp; RsPeResAVI = 'AVI';<br>&nbsp; RsPeResBitmap = 'Bitmap';<br>&nbsp; RsPeResCursor = 'Cursor';<br>&nbsp; RsPeResData = 'RCData';<br>&nbsp; RsPeResDialog = 'Dialog';<br>&nbsp; RsPeResHTML = 'HTML';<br>&nbsp; RsPeResIcon = 'Icon';<br>&nbsp; RsPeResMenu = 'Menu';<br>&nbsp; RsPeResMessageTable = 'Message table';<br>&nbsp; RsPeResString = 'String';<br>&nbsp; RsPeResVersion = 'Version';<br>&nbsp; RsNeutralLang = '[Neutral]';<br>&nbsp; RsUnknownLang = '[Unknown]';<br><br>&nbsp; RsTranslations = 'Translations:';<br><br>var<br>&nbsp; JclLocalesList: TJclLocalesList;<br><br>function VirtualKeyNameFromCode(KeyCode: Byte): string;<br>const<br>&nbsp; KN002F: array[$00..$2F] of PChar = (<br>&nbsp; &nbsp; nil,<br>&nbsp; &nbsp; 'LBUTTON',<br>&nbsp; &nbsp; 'RBUTTON',<br>&nbsp; &nbsp; 'CANCEL',<br>&nbsp; &nbsp; 'MBUTTON',<br>&nbsp; &nbsp; nil, nil, nil, // 05..07<br>&nbsp; &nbsp; 'BACK',<br>&nbsp; &nbsp; 'TAB',<br>&nbsp; &nbsp; nil, nil, // 0A..0B<br>&nbsp; &nbsp; 'CLEAR',<br>&nbsp; &nbsp; 'RETURN',<br>&nbsp; &nbsp; nil, nil, // 0E..0F<br>&nbsp; &nbsp; 'SHIFT ',<br>&nbsp; &nbsp; 'CONTROL',<br>&nbsp; &nbsp; 'MENU',<br>&nbsp; &nbsp; 'PAUSE',<br>&nbsp; &nbsp; 'CAPITAL',<br>&nbsp; &nbsp; 'KANA',<br>&nbsp; &nbsp; 'HANGUL',<br>&nbsp; &nbsp; 'JUNJA',<br>&nbsp; &nbsp; 'FINAL',<br>&nbsp; &nbsp; 'HANJA',<br>&nbsp; &nbsp; 'KANJI',<br>&nbsp; &nbsp; 'ESCAPE',<br>&nbsp; &nbsp; 'CONVERT',<br>&nbsp; &nbsp; 'NONCONVERT',<br>&nbsp; &nbsp; 'ACCEPT',<br>&nbsp; &nbsp; 'MODECHANGE',<br>&nbsp; &nbsp; 'SPACE',<br>&nbsp; &nbsp; 'PRIOR',<br>&nbsp; &nbsp; 'NEXT',<br>&nbsp; &nbsp; 'END',<br>&nbsp; &nbsp; 'HOME',<br>&nbsp; &nbsp; 'LEFT',<br>&nbsp; &nbsp; 'UP',<br>&nbsp; &nbsp; 'RIGHT',<br>&nbsp; &nbsp; 'DOWN',<br>&nbsp; &nbsp; 'SELECT',<br>&nbsp; &nbsp; 'PRINT',<br>&nbsp; &nbsp; 'EXECUTE',<br>&nbsp; &nbsp; 'SNAPSHOT',<br>&nbsp; &nbsp; 'INSERT',<br>&nbsp; &nbsp; 'DELETE',<br>&nbsp; &nbsp; 'HELP'<br>&nbsp; &nbsp; );<br>&nbsp; KN5B5D: array[$5B..$5D] of PChar = (<br>&nbsp; &nbsp; 'LWIN',<br>&nbsp; &nbsp; 'RWIN',<br>&nbsp; &nbsp; 'APPS'<br>&nbsp; &nbsp; );<br>&nbsp; KN6A6F: array[$6A..$6F] of PChar = (<br>&nbsp; &nbsp; 'MULTIPLY',<br>&nbsp; &nbsp; 'ADD',<br>&nbsp; &nbsp; 'SEPARATOR',<br>&nbsp; &nbsp; 'SUBTRACT',<br>&nbsp; &nbsp; 'DECIMAL',<br>&nbsp; &nbsp; 'DIVIDE'<br>&nbsp; &nbsp; );<br>&nbsp; KNA0A5: array[$A0..$A5] of PChar = (<br>&nbsp; &nbsp; 'LSHIFT',<br>&nbsp; &nbsp; 'RSHIFT',<br>&nbsp; &nbsp; 'LCONTROL',<br>&nbsp; &nbsp; 'RCONTROL',<br>&nbsp; &nbsp; 'LMENU',<br>&nbsp; &nbsp; 'RMENU'<br>&nbsp; &nbsp; );<br>&nbsp; KNF6FE: array[$F6..$FE] of PChar = (<br>&nbsp; &nbsp; 'ATTN',<br>&nbsp; &nbsp; 'CRSEL',<br>&nbsp; &nbsp; 'EXSEL',<br>&nbsp; &nbsp; 'EREOF',<br>&nbsp; &nbsp; 'PLAY',<br>&nbsp; &nbsp; 'ZOOM',<br>&nbsp; &nbsp; 'NONAME',<br>&nbsp; &nbsp; 'PA1',<br>&nbsp; &nbsp; 'OEM_CLEAR'<br>&nbsp; &nbsp; );<br>begin<br>&nbsp; case KeyCode of<br>&nbsp; &nbsp; $00..$2F:<br>&nbsp; &nbsp; &nbsp; Result := KN002F[KeyCode];<br>&nbsp; &nbsp; $30..$39, $41..$5A:<br>&nbsp; &nbsp; &nbsp; Result := Chr(KeyCode);<br>&nbsp; &nbsp; $5B..$5D:<br>&nbsp; &nbsp; &nbsp; Result := KN5B5D[KeyCode];<br>&nbsp; &nbsp; $60..$69:<br>&nbsp; &nbsp; &nbsp; Result := Format('NUMPAD%d', [KeyCode - $60]);<br>&nbsp; &nbsp; $6A..$6F:<br>&nbsp; &nbsp; &nbsp; Result := KN6A6F[KeyCode];<br>&nbsp; &nbsp; $70..$87:<br>&nbsp; &nbsp; &nbsp; Result := Format('F%d', [KeyCode - $6F]);<br>&nbsp; &nbsp; $90:<br>&nbsp; &nbsp; &nbsp; Result := 'NUMLOCK';<br>&nbsp; &nbsp; $91:<br>&nbsp; &nbsp; &nbsp; Result := 'SCROLL';<br>&nbsp; &nbsp; $A0..$A5:<br>&nbsp; &nbsp; &nbsp; Result := KNA0A5[KeyCode];<br>&nbsp; &nbsp; $E5:<br>&nbsp; &nbsp; &nbsp; Result := 'PROCESSKEY';<br>&nbsp; &nbsp; $F6..$FE:<br>&nbsp; &nbsp; &nbsp; Result := KNF6FE[KeyCode];<br>&nbsp; else<br>&nbsp; &nbsp; Result := '';<br>&nbsp; end;<br>&nbsp; if Result &lt;&gt; '' then Result := 'VK_' + Result;<br>end;<br><br>function LangNameFromName(const Name: string; ShortName: Boolean): string;<br>var<br>&nbsp; LangID: Word;<br>&nbsp; Locale: TJclLocaleInfo;<br>begin<br>&nbsp; LangID := PRIMARYLANGID(StrToIntDef(Name, 0));<br>&nbsp; if LangID = LANG_NEUTRAL then<br>&nbsp; &nbsp; if ShortName then Result := '' else Result := RsNeutralLang<br>&nbsp; else<br>&nbsp; begin<br>&nbsp; &nbsp; Locale := JclLocalesList.ItemFromLangIDPrimary[LangID];<br>&nbsp; &nbsp; if Locale &lt;&gt; nil then<br>&nbsp; &nbsp; &nbsp; with Locale do if ShortName then<br>&nbsp; &nbsp; &nbsp; &nbsp; Result := AbbreviatedLangName else Result := EnglishLangName<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; Result := RsUnknownLang;<br>&nbsp; end;<br>end;<br><br><br>function GetResItemKind(Item: TJclPeResourceItem; var Kind: TPeResKind): Boolean;<br>begin<br>&nbsp; Result := True;<br>&nbsp; Kind := rkUnknown;<br>&nbsp; with Item do<br>&nbsp; &nbsp; case ResourceType of<br>&nbsp; &nbsp; &nbsp; rtAccelerators:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkAccelerator;<br>&nbsp; &nbsp; &nbsp; rtCursorEntry, rtIconEntry, rtFont:<br>&nbsp; &nbsp; &nbsp; &nbsp; Result := False;<br>&nbsp; &nbsp; &nbsp; rtUserDefined:<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Name = 'AVI' then Kind := rkAvi;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Name = '2110' then Kind := rkHTML;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; rtBitmap:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkBitmap;<br>&nbsp; &nbsp; &nbsp; rtMenu:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkMenu;<br>&nbsp; &nbsp; &nbsp; rtDialog:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkDialog;<br>&nbsp; &nbsp; &nbsp; rtString:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkString;<br>&nbsp; &nbsp; &nbsp; rtRCData:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkData;<br>&nbsp; &nbsp; &nbsp; rtMessageTable:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkMessageTable;<br>&nbsp; &nbsp; &nbsp; rtCursor:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkCursor;<br>&nbsp; &nbsp; &nbsp; rtIcon:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkIcon;<br>&nbsp; &nbsp; &nbsp; rtVersion:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkVersion;<br>&nbsp; &nbsp; &nbsp; rtHmtl:<br>&nbsp; &nbsp; &nbsp; &nbsp; Kind := rkHTML;<br>&nbsp; &nbsp; end;<br>end;<br><br>const<br>&nbsp; ResItemClasses: array [TPeResKind] of TJclReResItemClass = (<br>&nbsp; &nbsp; TPeResAccelerator,<br>&nbsp; &nbsp; TPeResAvi,<br>&nbsp; &nbsp; TPeResBitmap,<br>&nbsp; &nbsp; TPeResCursor,<br>&nbsp; &nbsp; TPeResRCData,<br>&nbsp; &nbsp; TPeResDialog,<br>&nbsp; &nbsp; TPeResHTML,<br>&nbsp; &nbsp; TPeResIcon,<br>&nbsp; &nbsp; TPeResMenu,<br>&nbsp; &nbsp; TPeMessageTable,<br>&nbsp; &nbsp; TPeResString,<br>&nbsp; &nbsp; TPeResVersion,<br>&nbsp; &nbsp; TPeResUnknown<br>&nbsp; &nbsp; );<br><br>function WideCharToStr(WStr: PWChar; Len: Integer): string;<br>begin<br>&nbsp; if Len = 0 then Len := -1;<br>&nbsp; Len := WideCharToMultiByte(CP_ACP, 0, WStr, Len, nil, 0, nil, nil);<br>&nbsp; SetLength(Result, Len);<br>&nbsp; WideCharToMultiByte(CP_ACP, 0, WStr, Len, PChar(Result), Len, nil, nil);<br>end;<br><br>{ TPeResItem }<br><br>constructor TPeResItem.Create(AResImage: TPeResImage; AResourceItem: TJclPeResourceItem);<br>begin<br>&nbsp; FList := TObjectList.Create(True);<br>&nbsp; FResImage := AResImage;<br>&nbsp; FResourceItem := AResourceItem;<br>end;<br><br>procedure TPeResItem.CreateList;<br>var<br>&nbsp; I, J: Integer;<br>&nbsp; Item: TPeResItem;<br>&nbsp; ResItem: TJclPeResourceItem;<br>begin<br>&nbsp; with FResourceItem.List do<br>&nbsp; &nbsp; for I := 0 to Count - 1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; ResItem := Items;<br>&nbsp; &nbsp; &nbsp; for J := 0 to ResItem.List.Count - 1 do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Item := ResItemClasses[Self.FKind].Create(FResImage, ResItem.List[J]);<br>&nbsp; &nbsp; &nbsp; &nbsp; Item.FKind := Self.FKind;<br>&nbsp; &nbsp; &nbsp; &nbsp; FList.Add(Item);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;<br><br>destructor TPeResItem.Destroy;<br>begin<br>&nbsp; FreeAndNil(FList);<br>&nbsp; FreeAndNil(FStream);<br>&nbsp; inherited;<br>end;<br><br>function TPeResItem.GetItemCount: Integer;<br>begin<br>&nbsp; if IsList then<br>&nbsp; begin<br>&nbsp; &nbsp; if FList.Count = 0 then CreateList;<br>&nbsp; &nbsp; Result := FList.Count;<br>&nbsp; end else<br>&nbsp; &nbsp; Result := -1;<br>end;<br><br>function TPeResItem.GetItems(Index: Integer): TPeResItem;<br>begin<br>&nbsp; Result := TPeResItem(FList[Index]);<br>end;<br><br>function TPeResItem.GetStream: TJclPeResourceRawStream;<br>begin<br>&nbsp; if not Assigned(FStream) then<br>&nbsp; &nbsp; FStream := TJclPeResourceRawStream.Create(FResourceItem);<br>&nbsp; Result := FStream;<br>end;<br><br>function TPeResItem.IsList: Boolean;<br>begin<br>&nbsp; Result := FResourceItem.IsDirectory;<br>end;<br><br>function TPeResItem.Offset: Integer;<br>begin<br>&nbsp; if IsList then<br>&nbsp; &nbsp; Result := FResourceItem.Entry^.OffsetToData and not (IMAGE_RESOURCE_DATA_IS_DIRECTORY)<br>&nbsp; else<br>&nbsp; &nbsp; Result := FResourceItem.DataEntry^.OffsetToData<br>end;<br><br>function TPeResItem.RawData: Pointer;<br>begin<br>&nbsp; Result := FResourceItem.RawEntryData;<br>end;<br><br>function TPeResItem.ResName: string;<br>const<br>&nbsp; ResNames: array [TPeResKind] of PResStringRec = (<br>&nbsp; &nbsp; @RsPeResAccelerator,<br>&nbsp; &nbsp; @RsPeResAVI,<br>&nbsp; &nbsp; @RsPeResBitmap,<br>&nbsp; &nbsp; @RsPeResCursor,<br>&nbsp; &nbsp; @RsPeResData,<br>&nbsp; &nbsp; @RsPeResDialog,<br>&nbsp; &nbsp; @RsPeResHTML,<br>&nbsp; &nbsp; @RsPeResIcon,<br>&nbsp; &nbsp; @RsPeResMenu,<br>&nbsp; &nbsp; @RsPeResMessageTable,<br>&nbsp; &nbsp; @RsPeResString,<br>&nbsp; &nbsp; @RsPeResVersion,<br>&nbsp; &nbsp; nil<br>&nbsp; &nbsp; );<br>begin<br>&nbsp; if FKind = rkUnknown then<br>&nbsp; &nbsp; Result := FResourceItem.ResourceTypeStr<br>&nbsp; else<br>&nbsp; &nbsp; Result := LoadResString(ResNames[FKind]);<br>end;<br><br>function TPeResItem.ResType: TJclPeResourceKind;<br>begin<br>&nbsp; Result := FResourceItem.ResourceType;<br>end;<br><br>procedure TPeResItem.SaveToStream(Stream: TStream);<br>begin<br>&nbsp; if not IsList then<br>&nbsp; &nbsp; Stream.WriteBuffer(RawData^, Size);<br>end;<br><br>function TPeResItem.Size: Integer;<br>begin<br>&nbsp; if IsList then<br>&nbsp; &nbsp; Result := 0<br>&nbsp; else<br>&nbsp; &nbsp; Result := FResourceItem.DataEntry^.Size;<br>end;<br><br>{ TPeResUnknown }<br><br>function TPeResUnknown.FileExt: string;<br>begin<br>&nbsp; Result := 'bin';<br>end;<br><br>function TPeResUnknown.IsList: Boolean;<br>begin<br>&nbsp; Result := False;<br>end;<br><br>function TPeResUnknown.ResName: string;<br>begin<br>&nbsp; if StrToIntDef(FResourceItem.Name, 0) = LANG_NEUTRAL then<br>&nbsp; &nbsp; Result := FResourceItem.ParentItem.Name<br>&nbsp; else<br>&nbsp; &nbsp; Result := Format('%s &gt; %s', [FResourceItem.ParentItem.Name, LangNameFromName(FResourceItem.Name)]);<br>end;<br><br>{ TPeResUnkStrings }<br><br>procedure TPeResUnkStrings.AssignTo(Dest: TPersistent);<br>begin<br>&nbsp; if (Dest is TStrings) then<br>&nbsp; &nbsp; with TStrings(Dest) do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; BeginUpdate;<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; FillStrings(TStrings(Dest));<br>&nbsp; &nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; &nbsp; EndUpdate;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; inherited;<br>end;<br><br>function TPeResUnkStrings.FileExt: string;<br>begin<br>&nbsp; Result := 'txt';<br>end;<br><br>{ TPeResAccelTable }<br><br>procedure TPeResAccelerator.FillStrings(Strings: TStrings; StripCrLf: Boolean);<br>var<br>&nbsp; TableEntry: PAccelTableEntry;<br>&nbsp; IsLast: Boolean;<br>&nbsp; S: string;<br><br>&nbsp; function AnsiToChar(A: Word): string;<br>&nbsp; begin<br>&nbsp; &nbsp; if A &gt;= 32 then Result := Chr(A) else Result := '';<br>&nbsp; end;<br><br>begin<br>&nbsp; Strings.BeginUpdate;<br>&nbsp; try<br>&nbsp; &nbsp; TableEntry := RawData;<br>&nbsp; &nbsp; repeat<br>&nbsp; &nbsp; &nbsp; with TableEntry^ do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; IsLast := fFlags and $80 &lt;&gt; 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; if fFlags and FVIRTKEY &lt;&gt; 0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := Format('Virtual Key: %.2u "%s" ', [wAnsi, VirtualKeyNameFromCode(wAnsi)]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if fFlags and FSHIFT &lt;&gt; 0 then S := S + 'SHIFT ';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if fFlags and FCONTROL &lt;&gt; 0 then S := S + 'CTRL ';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if fFlags and FALT &lt;&gt; 0 then S := S + 'ALT ';<br>&nbsp; &nbsp; &nbsp; &nbsp; end else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := Format('ANSI character: %.2u "%s" ', [wAnsi, AnsiToChar(wAnsi)]);<br>&nbsp; &nbsp; &nbsp; &nbsp; if fFlags and FNOINVERT &lt;&gt; 0 then S := S + 'NOINVERT';<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; Strings.Add(TrimRight(S));<br>&nbsp; &nbsp; &nbsp; Inc(TableEntry);<br>&nbsp; &nbsp; until IsLast;<br>&nbsp; finally<br>&nbsp; &nbsp; Strings.EndUpdate;<br>&nbsp; end; &nbsp; &nbsp;<br>end;<br><br>{ TPeResAvi }<br><br>{$HINTS OFF}<br>type<br>&nbsp; TDirtyComponent = class(TPersistent)<br>&nbsp; private<br>&nbsp; &nbsp; FOwner: TComponent;<br>&nbsp; &nbsp; FName: TComponentName;<br>&nbsp; &nbsp; FTag: Longint;<br>&nbsp; &nbsp; FComponents: TList;<br>&nbsp; &nbsp; FFreeNotifies: TList;<br>&nbsp; &nbsp; FDesignInfo: Longint;<br>&nbsp; &nbsp; FVCLComObject: Pointer;<br>&nbsp; &nbsp; FComponentState: TComponentState;<br>&nbsp; end;<br>{$HINTS ON}<br><br>procedure TPeResAvi.AssignTo(Dest: TPersistent);<br>begin<br>&nbsp; if Dest is TAnimate then<br>&nbsp; begin<br>&nbsp; &nbsp; Include(TDirtyComponent(Dest).FComponentState, csLoading);<br>&nbsp; &nbsp; TAnimate(Dest).ResHandle := FResImage.LibHandle;<br>&nbsp; &nbsp; TAnimate(Dest).ResName := FResourceItem.ParentItem.ParameterName;<br>&nbsp; &nbsp; Exclude(TDirtyComponent(Dest).FComponentState, csLoading);<br>&nbsp; &nbsp; TAnimate(Dest).Reset;<br>&nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; inherited;<br>end;<br><br>function TPeResAvi.FileExt: string;<br>begin<br>&nbsp; Result := 'avi';<br>end;<br><br>{ TPeResBitmap }<br><br>procedure TPeResBitmap.AssignTo(Dest: TPersistent);<br>var<br>&nbsp; MemStream: TMemoryStream;<br>&nbsp; BitMap: TBitMap;<br>begin<br>&nbsp; if Dest is TPicture then<br>&nbsp; begin<br>&nbsp; &nbsp; BitMap := TPicture(Dest).Bitmap;<br>&nbsp; &nbsp; MemStream := TMemoryStream.Create;<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; SaveToStream(MemStream);<br>&nbsp; &nbsp; &nbsp; MemStream.Seek(0, soFromBeginning);<br>&nbsp; &nbsp; &nbsp; BitMap.LoadFromStream(MemStream);<br>&nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; MemStream.Free;<br>&nbsp; &nbsp; end<br>&nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; inherited;<br>end;<br><br>function TPeResBitmap.FileExt: string;<br>begin<br>&nbsp; Result := 'bmp';<br>end;<br><br>function TPeResBitmap.GraphicProperties: TPeGraphicProperties;<br>var<br>&nbsp; BI: PBitmapInfoHeader;<br>&nbsp; BC: PBitmapCoreHeader;<br>begin<br>&nbsp; BI := PBitmapInfoHeader(RawData);<br>&nbsp; if BI.biSize = SizeOf(TBitmapInfoHeader) then<br>&nbsp; begin<br>&nbsp; &nbsp; Result.Width := BI.biWidth;<br>&nbsp; &nbsp; Result.Height := BI.biHeight;<br>&nbsp; &nbsp; Result.BitsPerPixel := BI.biPlanes * BI.biBitCount;<br>&nbsp; end else<br>&nbsp; begin<br>&nbsp; &nbsp; BC := PBitmapCoreHeader(RawData);<br>&nbsp; &nbsp; Result.Width := BC.bcWidth;<br>&nbsp; &nbsp; Result.Height := BC.bcHeight;<br>&nbsp; &nbsp; Result.BitsPerPixel := BC.bcPlanes * BC.bcBitCount;<br>&nbsp; end;<br>end;<br><br>procedure TPeResBitmap.SaveToStream(Stream: TStream);<br><br>&nbsp; function GetDInColors(BitCount: Word): Integer;<br>&nbsp; begin<br>&nbsp; &nbsp; case BitCount of<br>&nbsp; &nbsp; &nbsp; 1, 4, 8: Result := 1 shl BitCount;<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; Result := 0;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br><br>var<br>&nbsp; BH: TBitmapFileHeader;<br>&nbsp; BI: PBitmapInfoHeader;<br>&nbsp; BC: PBitmapCoreHeader;<br>&nbsp; ClrUsed: Integer;<br>begin<br>&nbsp; FillChar(BH, sizeof(BH), #0);<br>&nbsp; BH.bfType := $4D42;<br>&nbsp; BH.bfSize := Size + SizeOf(BH);<br>&nbsp; BI := PBitmapInfoHeader(RawData);<br>&nbsp; if BI.biSize = SizeOf(TBitmapInfoHeader) then<br>&nbsp; begin<br>&nbsp; &nbsp; ClrUsed := BI.biClrUsed;<br>&nbsp; &nbsp; if ClrUsed = 0 then ClrUsed := GetDInColors(BI.biBitCount);<br>&nbsp; &nbsp; BH.bfOffBits := &nbsp;ClrUsed * SizeOf(TRgbQuad) + SizeOf(TBitmapInfoHeader) + SizeOf(BH);<br>&nbsp; end<br>&nbsp; else<br>&nbsp; begin<br>&nbsp; &nbsp; BC := PBitmapCoreHeader(RawData);<br>&nbsp; &nbsp; ClrUsed := GetDInColors(BC.bcBitCount);<br>&nbsp; &nbsp; BH.bfOffBits := &nbsp;ClrUsed * SizeOf(TRGBTriple) + SizeOf(TBitmapCoreHeader) + SizeOf(BH);<br>&nbsp; end;<br>&nbsp; Stream.Write(BH, SizeOf(BH));<br>&nbsp; Stream.Write(RawData^, Size);<br>end;<br><br>{ TPeResCursorItem }<br><br>procedure TPeResCursorItem.AssignTo(Dest: TPersistent);<br>begin<br>&nbsp; if Dest is TPicture then<br>&nbsp; &nbsp; TPicture(Dest).Icon.Handle := CreateIconFromResource(RawData, Size, ResType = rtIconEntry, $30000)<br>&nbsp; else<br>&nbsp; &nbsp; inherited;<br>end;<br><br>function TPeResCursorItem.FileExt: string;<br>begin<br>&nbsp; Result := 'cur';<br>end;<br><br>function TPeResCursorItem.GraphicProperties: TPeGraphicProperties;<br>begin<br>&nbsp; with FResInfo^ do<br>&nbsp; begin<br>&nbsp; &nbsp; Result.Width := ResInfo.Cursor.Width;<br>&nbsp; &nbsp; Result.Height := ResInfo.Cursor.Height;<br>&nbsp; &nbsp; Result.BitsPerPixel := BitCount * Planes;<br>&nbsp; end;<br>end;<br><br>function TPeResCursorItem.ResName: string;<br>begin<br>&nbsp; if FResInfo &lt;&gt; nil then<br>&nbsp; &nbsp; with GraphicProperties do<br>&nbsp; &nbsp; &nbsp; Result := Format('%d X %d %d bpp', [Width, Height, BitsPerPixel])<br>&nbsp; else<br>&nbsp; &nbsp; Result := '';<br>end;<br><br>procedure TPeResCursorItem.SaveToStream(Stream: TStream);<br>begin<br>&nbsp; with TIcon.Create do<br>&nbsp; try<br>&nbsp; &nbsp; Handle := CreateIconFromResource(RawData, Self.Size, ResType = rtIconEntry, $30000);<br>&nbsp; &nbsp; SaveToStream(Stream);<br>&nbsp; finally<br>&nbsp; &nbsp; Free;<br>&nbsp; end;<br>end;<br>{ TODO : Saving monochrome icons and cursors doesn't work }<br><br>{ TPeResCursor }<br><br>procedure TPeResCursor.CreateList;<br>var<br>&nbsp; Item: TPeResItem;<br>&nbsp; I, J, Cnt: Integer;<br>&nbsp; ResData: PResDir;<br>&nbsp; ResOrd: DWORD;<br>&nbsp; ResList: TJclPeResourceList;<br>&nbsp; ItemClass: TJclReResItemClass;<br>begin<br>&nbsp; if ResType = rtCursor then<br>&nbsp; begin<br>&nbsp; &nbsp; ResList := FResImage.FCursorEntry;<br>&nbsp; &nbsp; ItemClass := TPeResCursorItem;<br>&nbsp; end else<br>&nbsp; begin<br>&nbsp; &nbsp; ResList := FResImage.FIconEntry;<br>&nbsp; &nbsp; ItemClass := TPeResIconItem;<br>&nbsp; end;<br>&nbsp; ResData := RawData;<br>&nbsp; Cnt := PNewHeader(ResData)^.ResCount;<br>&nbsp; Inc(PNewHeader(ResData));<br>&nbsp; for I := 1 to Cnt do<br>&nbsp; begin<br>&nbsp; &nbsp; ResOrd := ResData^.IconCursorId;<br>&nbsp; &nbsp; for J := 0 to ResList.Count - 1 do<br>&nbsp; &nbsp; &nbsp; if ResOrd = ResList[J].Entry^.Name then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Item := ItemClass.Create(FResImage, ResList[J].List[0]);<br>&nbsp; &nbsp; &nbsp; &nbsp; Item.FKind := Self.FKind;<br>&nbsp; &nbsp; &nbsp; &nbsp; TPeResCursorItem(Item).FResInfo := ResData;<br>&nbsp; &nbsp; &nbsp; &nbsp; FList.Add(Item);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; Inc(ResData);<br>&nbsp; end;<br>end;<br><br>function TPeResCursor.GetItems(Index: Integer): TPeResCursorItem;<br>begin<br>&nbsp; Result := TPeResCursorItem(FList[Index]);<br>end;<br><br>function TPeResCursor.IsList: Boolean;<br>begin<br>&nbsp; Result := True;<br>end;<br><br>{ TPeResRCData }<br><br>procedure TPeResRCData.AssignTo(Dest: TPersistent);<br>begin<br>&nbsp; if Dest is TStrings then<br>&nbsp; &nbsp; with TStrings(Dest) do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; BeginUpdate;<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; case FDataKind of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dkDFM:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DFMToStrings(TStrings(Dest));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dkPackageDescription:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Add(PWideChar(RawData));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dkPackageInfo:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PackageInfoToStrings(TStrings(Dest));<br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; &nbsp; EndUpdate;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; end else<br>&nbsp; &nbsp; inherited;<br>end;<br><br>procedure TPeResRCData.CheckFormat;<br>begin<br>&nbsp; FDataKind := dkUnknown;<br>&nbsp; if ResName = 'DESCRIPTION' then<br>&nbsp; &nbsp; FDataKind := dkPackageDescription<br>&nbsp; else<br>&nbsp; if ResName = 'PACKAGEINFO' then<br>&nbsp; &nbsp; FDataKind := dkPackageInfo<br>&nbsp; else &nbsp;<br>&nbsp; begin<br>&nbsp; &nbsp; Stream.Seek(0, soFromBeginning);<br>&nbsp; &nbsp; if TestStreamFormat(Stream) = sofBinary then<br>&nbsp; &nbsp; &nbsp; FDataKind := dkDFM;<br>&nbsp; end;<br>end;<br><br>constructor TPeResRCData.Create(AResImage: TPeResImage;<br>&nbsp; AResourceItem: TJclPeResourceItem);<br>begin<br>&nbsp; inherited;<br>&nbsp; CheckFormat;<br>end;<br><br>procedure TPeResRCData.DFMToStrings(Strings: TStrings);<br>var<br>&nbsp; MemStream: TMemoryStream;<br>begin<br>&nbsp; MemStream := TMemoryStream.Create;<br>&nbsp; try<br>&nbsp; &nbsp; Stream.Seek(0, soFromBeginning);<br>&nbsp; &nbsp; ObjectBinaryToText(Stream, MemStream);<br>&nbsp; &nbsp; MemStream.Seek(0, soFromBeginning);<br>&nbsp; &nbsp; Strings.LoadFromStream(MemStream);<br>&nbsp; finally<br>&nbsp; &nbsp; MemStream.Free;<br>&nbsp; end;<br>end;<br><br>function TPeResRCData.FileExt: string;<br>begin<br>&nbsp; if DataKind = dkDFM then<br>&nbsp; &nbsp; Result := 'dfm'<br>&nbsp; else<br>&nbsp; &nbsp; Result := inherited FileExt;<br>end;<br><br>procedure TPeResRCData.PackageInfoToStrings(Strings: TStrings);<br>var<br>&nbsp; I: Integer;<br>begin<br>&nbsp; with TJclPePackageInfo.Create(FResImage.LibHandle) do<br>&nbsp; try<br>&nbsp; &nbsp; Strings.Add('Contains');<br>&nbsp; &nbsp; Strings.Add(StringOfChar('-', 80));<br>&nbsp; &nbsp; for I := 0 to ContainsCount - 1 do<br>&nbsp; &nbsp; &nbsp; Strings.Add(Format(' &nbsp;%s [%s]', [ContainsNames, UnitInfoFlagsToString(ContainsFlags)]));<br>&nbsp; &nbsp; if RequiresCount &gt; 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Strings.Add('');<br>&nbsp; &nbsp; &nbsp; Strings.Add('Requires');<br>&nbsp; &nbsp; &nbsp; Strings.Add(StringOfChar('-', 80));<br>&nbsp; &nbsp; &nbsp; for I := 0 to RequiresCount - 1 do<br>&nbsp; &nbsp; &nbsp; &nbsp; Strings.Add(Format(' &nbsp;%s', [RequiresNames]));<br>&nbsp; &nbsp; end; &nbsp; &nbsp;<br>&nbsp; &nbsp; Strings.Add('');<br>&nbsp; &nbsp; Strings.Add('Package Info flags');<br>&nbsp; &nbsp; Strings.Add(StringOfChar('-', 80));<br>&nbsp; &nbsp; Strings.Add(Format('Options &nbsp; &nbsp;: %s', [PackageOptionsToString(Flags)]));<br>&nbsp; &nbsp; Strings.Add(Format('Module type: %s', [PackageModuleTypeToString(Flags)]));<br>&nbsp; &nbsp; Strings.Add(Format('Producer &nbsp; : %s', [ProducerToString(Flags)]));<br>&nbsp; finally<br>&nbsp; &nbsp; Free;<br>&nbsp; end;<br>end;<br><br>{ TPeResDialog }<br><br>function TPeResDialog.CanShowDialog: Boolean;<br>begin<br>&nbsp; Result := Windows.PDlgTemplate(RawData)^.style and DS_CONTROL = 0;<br>end;<br><br>function TPeResDialog.ShowDialog(ParentWnd: HWND): Integer;<br>var<br>&nbsp; LastFocus: HWND;<br>&nbsp; MemHandle: THandle;<br>&nbsp; P: Windows.PDlgTemplate;<br><br>&nbsp; function DialogProc(hwndDlg: HWND; uMsg: UINT; W: WPARAM; L: LPARAM): BOOL; stdcall;<br>&nbsp; begin<br>&nbsp; &nbsp; Result := False;<br>&nbsp; &nbsp; case uMsg of<br>&nbsp; &nbsp; &nbsp; WM_INITDIALOG:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := True;<br>&nbsp; &nbsp; &nbsp; WM_LBUTTONDBLCLK:<br>&nbsp; &nbsp; &nbsp; &nbsp; EndDialog(hwndDlg, 0);<br>&nbsp; &nbsp; &nbsp; WM_RBUTTONUP:<br>&nbsp; &nbsp; &nbsp; &nbsp; EndDialog(hwndDlg, 1);<br>&nbsp; &nbsp; &nbsp; WM_SYSCOMMAND:<br>&nbsp; &nbsp; &nbsp; &nbsp; if W and $FFF0 = SC_CLOSE then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EndDialog(hwndDlg, 0);<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br><br>begin<br>&nbsp; LastFocus := GetFocus;<br>&nbsp; MemHandle := GlobalAlloc(GMEM_ZEROINIT, Size);<br>&nbsp; P := GlobalLock(MemHandle);<br>&nbsp; Move(RawData^, P^, Size);<br>&nbsp; GlobalUnlock(MemHandle);<br>&nbsp; Result := DialogBoxIndirect(hinstance, Windows.PDlgTemplate(MemHandle)^,<br>&nbsp; &nbsp; ParentWnd, @DialogProc);<br>&nbsp; GlobalFree(MemHandle);<br>&nbsp; SetFocus(LastFocus);<br>end;<br><br>{ TPeResHTML }<br><br>function TPeResHTML.FileExt: string;<br>begin<br>&nbsp; Result := Copy(ExtractFileExt(FResourceItem.ParentItem.ParameterName), 2, 20);<br>end;<br><br>function TPeResHTML.ResPath: string;<br>begin<br>&nbsp; Result := Format('res://%s/%s', [FResImage.FileName, FResourceItem.ParentItem.ParameterName]);<br>end;<br><br>{ TPeResIconItem }<br><br>function TPeResIconItem.FileExt: string;<br>begin<br>&nbsp; Result := 'ico';<br>end;<br><br>function TPeResIconItem.GraphicProperties: TPeGraphicProperties;<br>begin<br>&nbsp; with FResInfo^ do<br>&nbsp; begin<br>&nbsp; &nbsp; Result.Width := ResInfo.Icon.Width;<br>&nbsp; &nbsp; Result.Height := ResInfo.Icon.Height;<br>&nbsp; &nbsp; Result.BitsPerPixel := BitCount * Planes;<br>&nbsp; end;<br>end;<br><br>{ TPeResIcon }<br><br>function TPeResIcon.GetItems(Index: Integer): TPeResIconItem;<br>begin<br>&nbsp; Result := TPeResIconItem(FList[Index]);<br>end;<br><br>{ TPeMessageTable }<br><br>procedure TPeMessageTable.FillStrings(Strings: TStrings; StripCrLf: Boolean);<br>var<br>&nbsp; Count, I: Integer;<br>&nbsp; E: DWORD;<br>&nbsp; Block: PMessageResourceBlock;<br>&nbsp; Entry: PMessageResourceEntry;<br>&nbsp; S: string;<br>&nbsp; Text: PChar;<br>&nbsp; Data: Pointer;<br>begin<br>&nbsp; Data := RawData;<br>&nbsp; Count := PMessageResourceData(Data)^.NumberOfBlocks;<br>&nbsp; Block := Data;<br>&nbsp; Inc(PMessageResourceData(Block));<br>&nbsp; for I := 1 to Count do<br>&nbsp; begin<br>&nbsp; &nbsp; Entry := PMessageResourceEntry(DWORD(Data) + Block^.OffsetToEntries);<br>&nbsp; &nbsp; for E := Block^.LowId to Block^.HighId do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; with Entry^ do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Text := PChar(Entry) + Sizeof(TMessageResourceEntry);<br>&nbsp; &nbsp; &nbsp; &nbsp; if Flags = 1 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := WideCharToStr(PWideChar(Text), lstrlenW(PWideChar(Text)))<br>&nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetString(S, PAnsiChar(Text), StrLen(Text));<br>&nbsp; &nbsp; &nbsp; &nbsp; if StripCrLf then S := StrRemoveChars(S, [AnsiCarriageReturn, AnsiLineFeed]);<br>&nbsp; &nbsp; &nbsp; &nbsp; Strings.AddObject(S, Pointer(E));<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; Entry := Pointer(PChar(Entry) + Entry^.Length);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; Inc(Block);<br>&nbsp; end;<br>end;<br><br>{ TPeResString }<br><br>procedure TPeResString.FillStrings(Strings: TStrings; StripCrLf: Boolean);<br>var<br>&nbsp; P: PWChar;<br>&nbsp; ID: Integer;<br>&nbsp; Cnt: Cardinal;<br>&nbsp; Len: Word;<br>&nbsp; S: string;<br>begin<br>&nbsp; P := RawData;<br>&nbsp; Cnt := 0;<br>&nbsp; while Cnt &lt; 16 do<br>&nbsp; begin<br>&nbsp; &nbsp; Len := Word(P^);<br>&nbsp; &nbsp; if Len &gt; 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Inc(P);<br>&nbsp; &nbsp; &nbsp; ID := ((FResourceItem.ParentItem.Entry^.Name - 1) shl 4) + Cnt;<br>&nbsp; &nbsp; &nbsp; S := WideCharToStr(P, Len);<br>&nbsp; &nbsp; &nbsp; if StripCrLf then S := StrRemoveChars(S, [AnsiCarriageReturn, AnsiLineFeed]);<br>&nbsp; &nbsp; &nbsp; Strings.AddObject(S, Pointer(ID));<br>&nbsp; &nbsp; &nbsp; Inc(P, Len);<br>&nbsp; &nbsp; end else<br>&nbsp; &nbsp; &nbsp; Inc(P);<br>&nbsp; &nbsp; Inc(Cnt);<br>&nbsp; end;<br>end;<br><br>{ TPeResVersion }<br><br>procedure TPeResVersion.FillStrings(Strings: TStrings; StripCrLf: Boolean);<br>var<br>&nbsp; I: Integer;<br>begin<br>&nbsp; Strings.Clear;<br>&nbsp; with TJclFileVersionInfo.Attach(RawData, Size) do<br>&nbsp; try<br>&nbsp; &nbsp; for I := 0 to LanguageCount - 1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; LanguageIndex := I;<br>&nbsp; &nbsp; &nbsp; Strings.Add(Format('[%s] %s', [LanguageIds, LanguageNames]));<br>&nbsp; &nbsp; &nbsp; Strings.Add(StringOfChar('-', 80));<br>&nbsp; &nbsp; &nbsp; Strings.AddStrings(Items);<br>&nbsp; &nbsp; &nbsp; Strings.Add(BinFileVersion);<br>&nbsp; &nbsp; &nbsp; Strings.Add(OSIdentToString(FileOS));<br>&nbsp; &nbsp; &nbsp; Strings.Add(OSFileTypeToString(FileType, FileSubType));<br>&nbsp; &nbsp; &nbsp; Strings.Add('');<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; Strings.Add(RsTranslations);<br>&nbsp; &nbsp; for I := 0 to TranslationCount - 1 do<br>&nbsp; &nbsp; &nbsp; Strings.Add(VersionLanguageId(Translations));<br>&nbsp; finally<br>&nbsp; &nbsp; Free;<br>&nbsp; end;<br>end;<br><br>{ TPeResImage }<br><br>procedure TPeResImage.Clear;<br>begin<br>&nbsp; inherited;<br>&nbsp; if Assigned(FPeImage) then<br>&nbsp; begin<br>&nbsp; &nbsp; if not FImageAttached then FreeAndNil(FPeImage) else FPeImage := nil;<br>&nbsp; end;<br>end;<br><br>constructor TPeResImage.Create;<br>begin<br>&nbsp; inherited Create(True);<br>end;<br><br>procedure TPeResImage.CreateList;<br>var<br>&nbsp; I: Integer;<br>&nbsp; Kind: TPeResKind;<br>&nbsp; Item: TJclPeResourceItem;<br>&nbsp; ResItem: TPeResItem;<br>begin<br>&nbsp; with FPeImage.ResourceList do<br>&nbsp; &nbsp; for I := 0 to Count - 1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Item := Items;<br>&nbsp; &nbsp; &nbsp; if GetResItemKind(Item, Kind) then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ResItem := TPeResItem.Create(Self, Item);<br>&nbsp; &nbsp; &nbsp; &nbsp; ResItem.FKind := Kind;<br>&nbsp; &nbsp; &nbsp; &nbsp; Self.Add(ResItem);<br>&nbsp; &nbsp; &nbsp; end else<br>&nbsp; &nbsp; &nbsp; case Item.ResourceType of<br>&nbsp; &nbsp; &nbsp; &nbsp; rtCursorEntry:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FCursorEntry := Item.List;<br>&nbsp; &nbsp; &nbsp; &nbsp; rtIconEntry:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FIconEntry := Item.List;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end; &nbsp;<br>end;<br><br>destructor TPeResImage.Destroy;<br>begin<br>&nbsp; UnloadLib;<br>&nbsp; inherited;<br>end;<br><br>function TPeResImage.GetFileName: TFileName;<br>begin<br>&nbsp; if Assigned(FPeImage) then Result := FPeImage.FileName else Result := '';<br>end;<br><br>function TPeResImage.GetItems(Index: Integer): TPeResItem;<br>begin<br>&nbsp; Result := TPeResItem(inherited Items[Index]);<br>end;<br><br>function TPeResImage.GetLibHandle: THandle;<br>begin<br>&nbsp; if FLibHandle = 0 then<br>&nbsp; begin<br>&nbsp; &nbsp; FLibHandle := LoadLibraryEx(PChar(FileName), 0, LOAD_LIBRARY_AS_DATAFILE);<br>&nbsp; &nbsp; if FLibHandle = 0 then RaiseLastWin32Error;<br>&nbsp; end; &nbsp;<br>&nbsp; Result := FLibHandle;<br>end;<br><br>procedure TPeResImage.SetFileName(const Value: TFileName);<br>begin<br>&nbsp; if FileName &lt;&gt; Value then<br>&nbsp; begin<br>&nbsp; &nbsp; Clear;<br>&nbsp; &nbsp; FImageAttached := False;<br>&nbsp; &nbsp; FPeImage := TJclPeImage.Create;<br>&nbsp; &nbsp; FPeImage.FileName := Value;<br>&nbsp; &nbsp; CreateList;<br>&nbsp; end;<br>end;<br><br>procedure TPeResImage.SetPeImage(const Value: TJclPeImage);<br>begin<br>&nbsp; Clear;<br>&nbsp; FPeImage := Value;<br>&nbsp; FImageAttached := True;<br>&nbsp; CreateList;<br>end;<br><br>procedure TPeResImage.UnloadLib;<br>begin<br>&nbsp; if FLibHandle &lt;&gt; 0 then<br>&nbsp; begin<br>&nbsp; &nbsp; FreeLibrary(FLibHandle);<br>&nbsp; &nbsp; FLibHandle := 0;<br>&nbsp; end;<br>end;<br><br>initialization<br>&nbsp; JclLocalesList := TJclLocalesList.Create;<br><br>finalization<br>&nbsp; FreeAndNil(JclLocalesList);<br><br>end.<br>
 
用PSAPI!但我只有一个简单的BCB的例子。<br>
 
1、<br>function GetModulesofProcess(const ProcessID: DWORD): String;<br>var<br>&nbsp; lpme: TModuleEntry32;<br>&nbsp; SsHandle: THandle;<br>&nbsp; FoundAProc: Boolean;<br>begin<br>&nbsp; lpme.dwSize := SizeOf(lpme);<br><br>&nbsp; ssHandle := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE, ProcessID);<br>&nbsp; FoundAProc := Module32First(SsHandle, lpme);<br><br>&nbsp; if FoundAProc then<br>&nbsp; begin<br>&nbsp; &nbsp; Result := lpme.szExePath;<br>&nbsp; end<br>&nbsp; else Result := '';<br>&nbsp; CloseHandle(SsHandle);<br>end;<br><br>var<br>&nbsp; &nbsp; handles:Thandle; &nbsp;//进程名柄<br>&nbsp; &nbsp; ppro:TProcessEntry32; //进程记录结构<br>&nbsp; &nbsp; //ppro1:Tmoduleentry32;<br>&nbsp; &nbsp; bl:bool;<br>&nbsp; &nbsp; ls_Str:string;<br>begin<br>&nbsp; &nbsp;handles:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br>&nbsp; &nbsp; ppro.dwsize:=sizeof(Tprocessentry32);<br>&nbsp; &nbsp; bl:= process32first(handles,ppro);<br>&nbsp; &nbsp; while bl do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; with listview1.items.add do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;caption:=(ppro.szexefile);//如果在98下,这里的szexefile包含了路径<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//如果在2000/XP下,可以这样获得其全路径:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetModulesofProcess(ppro.th32ProcessID);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;subitems.add(inttostr(ppro.pcPriClassBase));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;subitems.add(inttostr(ppro.th32ProcessID));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; bl:=process32next(handles,ppro);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; CloseHandle(handles);<br>end;<br>
 
winnt、win2k、winxp下可以用未公开的native api。<br>win9x 查看msdn help 有很多函数。
 
后退
顶部