我写了一个DLL,其DLL中有一个Procdeure,我为什么能静态调用此DLL,而不能动态调用呢?
动态调用:
Type
TBOMExport = Procedure (H:THandle;ItName:Pchar;BoMTree:TTreeView);StdCall; EDllLoadError = Class(Exception);....
// 调用部份LibHandle:=LoadLibrary('ProBomTree.DLL');
Try
If LibHandle = 0 then
Raise EDLLLoadError.Create('不能加载DLL');
@BOMExpand:=GetProcAddress(LibHandle,'BOMExpand');
if Not(@BOMExpand=nil) Then
Begin
BOMExpand(Application.Handle,Pchar(TItem.Text),BoMTree);
End
Else
RaiseLastWin32Error;
Finally
FreeLibrary(LibHandle);
End;
动态调用:
Type
TBOMExport = Procedure (H:THandle;ItName:Pchar;BoMTree:TTreeView);StdCall; EDllLoadError = Class(Exception);....
// 调用部份LibHandle:=LoadLibrary('ProBomTree.DLL');
Try
If LibHandle = 0 then
Raise EDLLLoadError.Create('不能加载DLL');
@BOMExpand:=GetProcAddress(LibHandle,'BOMExpand');
if Not(@BOMExpand=nil) Then
Begin
BOMExpand(Application.Handle,Pchar(TItem.Text),BoMTree);
End
Else
RaiseLastWin32Error;
Finally
FreeLibrary(LibHandle);
End;
我将BOMExpand露出来了,但还是一样啊,,我在DLL中EXPORT 的名字是BOMExpand啊
这样写试试
BOMExpand:=GetProcAddress(LibHandle,'BOMExpand');
if Not(BOMExpand=nil) Then//这里柯
Begin
TbomExport(BOMExpand)(Application.Handle,Pchar(TItem.Text),BoMTree);
End
Else
ShowMessage('ERROR');