Find a few, and finally found a useful
function Getdllfileexports (
Szfilename:pchar;
Mstrings:tstrings
): Boolean;
Var
Hfile:thandle;
Hfilemapping:thandle;
Lpfilebase:pointer;
Pimg_dos_header:pimagedosheader;
Pimg_nt_header:pimagentheaders;
Pimg_export_dir:pimageexportdirectory;
Ppdwnames: ^pdword;
Szfunc:pchar;
I:integer;
Begin
Result: = False;
If not Assigned (mstrings) then Exit;
hfile: = CreateFile (szFileName, Generic_read, File_share_read, Nil,
open_existing, File_attribute_normal, 0);
if (hfile = invalid_handle_value) then Exit;
Hfilemapping: = createfilemapping (hfile, Nil, page_readonly, 0, 0, nil);
If hfilemapping = 0 Then
Begin
CloseHandle (hfile);
Exit;
End
Lpfilebase: = MapViewOfFile (hfilemapping, file_map_read, 0, 0, 0);
If lpfilebase = Nil Then
Begin
CloseHandle (hfilemapping);
CloseHandle (hfile);
Exit;
End
Pimg_dos_header: = Pimagedosheader (lpfilebase);
Pimg_nt_header: = Pimagentheaders (
Integer (pimg_dos_header) + integer (pimg_dos_header._lfanew));
If IsBadReadPtr (Pimg_nt_header, SizeOf (image_nt_headers)) or
(pimg_nt_header.signature <> image_nt_signature) Then
Begin
UnmapViewOfFile (lpfilebase);
CloseHandle (hfilemapping);
CloseHandle (hfile);
Exit;
End
Pimg_export_dir: = Pimageexportdirectory (
Pimg_nt_header.optionalheader.datadirectory[image_directory_entry_export].
virtualaddress);
If not Assigned (Pimg_export_dir) Then
Begin
UnmapViewOfFile (lpfilebase);
CloseHandle (hfilemapping);
CloseHandle (hfile);
Exit;
End
6E 2E 6F 6D
Pimg_export_dir: = Pimageexportdirectory (
Imagervatova (Pimg_nt_header, Pimg_dos_header, DWORD (Pimg_export_dir),
Pimagesectionheader (Pointer (nil) ^)));
Ppdwnames: = Pointer (Pimg_export_dir.addressofnames);
Ppdwnames: = Pointer (Imagervatova (Pimg_nt_header, Pimg_dos_header,
DWORD (Ppdwnames), Pimagesectionheader (Pointer (nil) ^)));
If not Assigned (ppdwnames) Then
Begin
UnmapViewOfFile (lpfilebase);
CloseHandle (hfilemapping);
CloseHandle (hfile);
Exit;
End
For I: = 0 to Pimg_export_dir.numberofnames-1 do
Begin
Szfunc: = PChar (Imagervatova (Pimg_nt_header, Pimg_dos_header,
DWORD (ppdwnames^), Pimagesectionheader (Pointer (nil) ^)));
Mstrings.add (Szfunc);
INC (Ppdwnames);
End
UnmapViewOfFile (lpfilebase);
CloseHandle (hfilemapping);
CloseHandle (hfile);
Result: = True;
End
Invoke Example
Procedure Tf_main.btntestclick (Sender:tobject);
Begin
Getdllfileexports (' f:\ disc burning \reclib\librtmp.dll ', memo1.lines);
End
http://blog.csdn.net/youthon/article/details/7666727
Delphi get DLL List of functions