Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to retrieve list of exported functions from a DLL Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
15-Sep-02
Category
Algorithm
Language
Delphi 2.x
Views
152
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert

Retrieve list of exported functions from a DLL

Answer:

To retrieve the list of exported functions from a DLL, pass the DLL name and a 
TStrings object to the function ListDLLFunctions() shown below.

This does not show the parameters for each export, which you can only get from the 
author of the DLL. 


1   program Project1;
2   
3   uses
4     Forms,
5     Classes,
6     SysUtils,
7     Dialogs,
8     ImageHlp, // routines to access debug information
9     Windows;
10  
11  
12  procedure ListDLLFunctions(DLLName: string; List: TStrings);
13  type
14    chararr = array[0..$FFFFFF] of Char;
15  var
16    H: THandle;
17    I, fc: integer;
18    st: string;
19    arr: Pointer;
20    ImageDebugInformation: PImageDebugInformation;
21  begin
22    List.Clear;
23    DLLName := ExpandFileName(DLLName);
24    if FileExists(DLLName) then
25    begin
26      H := CreateFile(PChar(DLLName), GENERIC_READ, FILE_SHARE_READ or
27        FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
28      if H <> INVALID_HANDLE_VALUE then
29      try
30        ImageDebugInformation := MapDebugInformation(H, PChar(DLLName), nil, 0);
31        if ImageDebugInformation <> nil then
32        try
33          arr := ImageDebugInformation^.ExportedNames;
34          fc := 0;
35          for I := 0 to ImageDebugInformation^.ExportedNamesSize - 1 do
36            if chararr(arr^)[I] = #0 then
37            begin
38              st := PChar(@chararr(arr^)[fc]);
39              if Length(st) > 0 then
40                List.Add(st);
41              if (I > 0) and (chararr(arr^)[I - 1] = #0) then
42                Break;
43              fc := I + 1
44            end
45        finally
46          UnmapDebugInformation(ImageDebugInformation)
47        end
48      finally
49        CloseHandle(H)
50      end
51    end
52  end;
53  
54  // the following is an example how to use the procedure
55  var
56    List: TStrings;
57    I: integer;
58    S: string;
59  
60  begin
61    List := TStringList.Create;
62  
63    ListDLLFunctions('c:\winnt\system32\mfc42.dll', List);
64  
65    S := 'List of functions';
66    for I := 0 to List.Count - 1 do
67      S := S + #13#10 + List[I];
68    ShowMessage(S);
69    List.Free
70  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC