Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
500 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (3)


Listing all Functions of a DLL FileFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 3.x (or higher)
Category:
System
Skill Level:
Scoring:
Last Update:
02/01/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet DLL Procedure Function Windows API
Times Scored:
3
Visits:
4982
Uploader: Matheus Pecci
Company:
Reference: N/A
 
Question/Problem/Abstract:
How to list all functios and procedures of a dll file ??
Answer:



Add the unit ImageHlp in USES of the form.



procedure ListDLLFunctions(DLLName: String; List: TStrings);
type
chararr = array [0..$FFFFFF] of Char;
var H: THandle;
    I,
    fc: integer;
    st: string;
    arr: Pointer;
    ImageDebugInformation: PImageDebugInformation;

begin
  List.Clear;
  DLLName := ExpandFileName(DLLName);
  if FileExists(DLLName) then
  begin
    H := CreateFile(PChar(DLLName), GENERIC_READ, FILE_SHARE_READ or
    FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    if H<>INVALID_HANDLE_VALUE then
      try
        ImageDebugInformation := MapDebugInformation(H, PChar(DLLName), nil, 0);
        if ImageDebugInformation<>nil then
          try
            arr := ImageDebugInformation^.ExportedNames;
            fc := 0;
            for I := 0 to ImageDebugInformation^.ExportedNamesSize - 1 do
              if chararr(arr^)[I]=#0 then
              begin
                st := PChar(@chararr(arr^)[fc]);
                if Length(st)>0 then
                  List.Add(st);
                  if (I>0) and (chararr(arr^)[I-1]=#0) then
                    Break;
                  fc := I + 1
              end
          finally
            UnmapDebugInformation(ImageDebugInformation)
          end
      finally
        CloseHandle(H)
      end
  end
end;



To call this procedure in your application, put a button and a list box in your form and do the follow:

procedure TForm1.Button1Click(Sender: TObject);
var
List: TStrings;
I: integer;

begin
  List := TStringList.Create;
  listbox1.clear;
  ListDLLFunctions('PATH OF DLL', List);
  for I := 0 to List.Count - 1 do
    listbox1.items.add(list[i]);
  List.Free
end;





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Article already written
    Vimil Saju (Feb 4 2002 7:30AM)

I have already written an article on how to get the list of files exported by a dll. please see articles 1732 and 1283. These articles show how to get the list of files exported by a dll as well as the functions imported by an executable without using imagehlp.dll
Respond

It does not work
Se erfd (Feb 15 2002 6:53AM)

Please see again this function
I have tested it some times , but I have get only
Empty message ....
Please public new message if have an eror ...
Respond

RE: Article already written
Alex Lacy (Mar 8 2002 5:07PM)

The function Does not work
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
I. Siticov
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)