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