Delphi 读取dll所有输出函数名


本文整理自网络,侵删。

 取得某一dll所有输出函数名
在uses里加上ImageHlp

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;

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

begin
List := TStringList.Create;

ListDLLFunctions('c:windowssystemAbcsda.dll', List);
showmessage(inttostr(list.count));
S := 'List of functions';
for I := 0 to List.Count - 1 do
S := S + #13#10 + List[I];
ShowMessage(S);

List.Free
end;

相关阅读 >>

Delphi winapi: getwindowthreadprocessid - 获取指定窗口的进程 id 或线程 id

行为判断Delphi中窗体最大化与最小化事件

Delphi服务器端如何防止ddos

Delphi ioutils 单元(5): tdirectory.tdirectory 的其他功能

Delphi资源文件的详细使用方法

Delphi xe android的所有权限按照分类总结说明

Delphi ado连接数据库

Delphi里实现获取资源管理器路径以及ie打开网址列表

Delphi datetimetogmt gmt时间与tdatetime转换

Delphi setformfullscreen()窗体全屏显示

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...