下面那个例子是我写的一个dll调用,但并没有发现你所说的情况,无论中间是否由其他操作,都完全可以退回到调用的Application,关键在于handle在谁手中
--------------------------------------
unit _UserInfo;
interface
uses stdctrls,sysutils,classes,windows,Dialogs,_Verify;
type
TMakeUserInfo = procedure (g_User:string;ahandle:Thandle);stdcall;
procedure GetFormUserInfo;
implementation
procedure GetFormUserInfo;
var
MakeUserInfo:TMakeUserInfo;
SysHandle:THandle;
begin
SysHandle:=0;
try
if SysHandle=0 then
begin
try
SysHandle:=LoadLibrary('UserInfo.Dll');
if not (SysHandle=0)
then
try
@MakeUserInfo:=GetProcAddress(SysHandle,'MakeUserInfo')
except
MessageDlg('UserInfo.Dll 内存地址定位失败',mterror,[mbok],1);
end
else
MessageDlg('UserInfo.Dll 载入内存失败',mterror,[mbok],1);
if not (@MakeUserInfo=nil) then
MakeUserInfo(G_USER,SysHandle);
finally
FreeLibrary(SysHandle);
end;
end;
except
on E:Exception do
begin
MessageDlg('错误:'+#13+E.Message,mterror,[mbok],1);
end;
end;
end;
end.