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

33 Visitors Online


 
...display the exported Dll functions?
Autor: unknown
[ Print tip ]  

Tip Rating (22):  
     




uses
  
ImageHlp;

procedure ListDLLExports(const FileName: string; List: TStrings);
type
  
TDWordArray = array [0..$FFFFF] of DWORD;
var
  
imageinfo: LoadedImage;
  pExportDirectory: PImageExportDirectory;
  dirsize: Cardinal;
  pDummy: PImageSectionHeader;
  i: Cardinal;
  pNameRVAs: ^TDWordArray;
  Name: string;
begin
  
List.Clear;
  if MapAndLoad(PChar(FileName), nil, @imageinfo, True, True) then
  begin
    try
      
pExportDirectory := ImageDirectoryEntryToData(imageinfo.MappedAddress,
        False, IMAGE_DIRECTORY_ENTRY_EXPORT, dirsize);
      if (pExportDirectory <> nilthen
      begin
        
pNameRVAs := ImageRvaToVa(imageinfo.FileHeader, imageinfo.MappedAddress,
          DWORD(pExportDirectory^.AddressOfNames), pDummy);
        for i := 0 to pExportDirectory^.NumberOfNames - 1 do
        begin
          
Name := PChar(ImageRvaToVa(imageinfo.FileHeader, imageinfo.MappedAddress,
            pNameRVAs^[i], pDummy));
          List.Add(Name);
        end;
      end;
    finally
      
UnMapAndLoad(@imageinfo);
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  
List: TStrings;
  i: Integer;
  s: string;
begin
  
List := TStringList.Create;
  try
    
ListDLLExports('C:\WINDOWS\SYSTEM32\browseui.dll', List);
    ShowMessage(IntToStr(list.Count) + ' functions in dll');
    s := 'List of functions:';
    for i := 0 to List.Count - 1 do
      
s := s + #13#10 + List[i];
    ShowMessage(S);
  finally
    
List.Free
  end;
end;

 

Rate this tip:

poor
very good


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