Mega Code Archive

 
Categories / Delphi / System
 

Listing all Functions of a DLL File

Title: Listing all Functions of a DLL File Question: 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 HINVALID_HANDLE_VALUE then try ImageDebugInformation := MapDebugInformation(H, PChar(DLLName), nil, 0); if ImageDebugInformationnil 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 (I0) 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;