whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

29 Visitors Online


 
...get all the resource names that are loaded in a given application?
Autor: P. Below
Homepage: http://info.borland.com/newsgroups/teamb/
[ Print tip ]  

Tip Rating (20):  
     


type
  
TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
  end
;

var
  
Form1: TForm1;

implementation

{$R *.dfm}

function enumResNamesProc(module: HMODULE; restype, resname: PChar;
  list: TStrings): Integer; stdcall;
begin
  if 
HiWord(Cardinal(resname)) <> 0 then
    
list.Add('  ' + resname)
  else
    
list.Add(Format('  #%d', [loword(Cardinal(resname))]));
  Result := 1;
end;

Function StockResourceType(restype: PChar): string;
const
  
restypenames: Array [1..22] of String =
    ( 'RT_CURSOR', //       = MakeIntResource(1);
      
'RT_BITMAP', //       = MakeIntResource(2);
      
'RT_ICON',   //       = MakeIntResource(3);
      
'RT_MENU',   //       = MakeIntResource(4);
      
'RT_DIALOG', //       = MakeIntResource(5);
      
'RT_STRING', //       = MakeIntResource(6);
      
'RT_FONTDIR',//       = MakeIntResource(7);
      
'RT_FONT',   //       = MakeIntResource(8);
      
'RT_ACCELERATOR',//   = MakeIntResource(9);
      
'RT_RCDATA', //       = MakeIntResource(10);
      
'RT_MESSAGETABLE',//  = MakeIntResource(11);
      // DIFFERENCE = 11;
      
'RT_GROUP_CURSOR',// = MakeIntResource(DWORD(RT_CURSOR +7DIFFERENCE));
      
'UNKNOWN',        // 13 not used
      
'RT_GROUP_ICON',  //   = MakeIntResource(DWORD(RT_ICON +DIFFERENCE));
      
'UNKNOWN',        // 15 not used
      
'RT_VERSION',     // = MakeIntResource(16);
      
'RT_DLGINCLUDE',  // = MakeIntResource(17);
      
'UNKNOWN',
      'RT_PLUGPLAY',    // = MakeIntResource(19);
      
'RT_VXD',         // = MakeIntResource(20);
      
'RT_ANICURSOR',   // = MakeIntResource(21);
      
'RT_ANIICON'     // = MakeIntResource(22);
    
);
var
  
resid: Cardinal absolute restype;
begin
  if 
resid in [1..22] then
    
Result := restypenames[resid]
  else
    
Result := 'UNKNOWN';
end;


function enumResTypesProc(module: HMODULE; restype: PChar; list: TStrings): Integer; stdcall;
begin
  if 
HiWord(Cardinal(restype)) <> 0 then
    
list.Add(restype)
  else
    
list.Add(Format('Stock type %d: %s', [LoWord(Cardinal(restype)),
      StockResourcetype(restype)]));
  EnumResourceNames(module, restype, @enumResNamesProc, Integer(list));
  Result := 1;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
memo1.Clear;
  if not EnumResourceTypes(hinstance, @enumResTypesProc, Integer(memo1.Lines)) then
    
memo1.Lines.Add(Format('GetLastError= %8.8x', [GetLastError]))
  else
    
memo1.Lines.Add('Successful');
end;

end.



 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners