我在dll里建了一个FORM 在Form里用了 Create事件加了 Application.OnMessage := WMDropMessage;
procedure Tfm_TS.WMDropMessage(var Msg: TMsg; var Handled: Boolean);
var
……
begin
……
end;当退出时报错,怎么解决啊????????????
procedure Tfm_TS.WMDropMessage(var Msg: TMsg; var Handled: Boolean);
var
……
begin
……
end;当退出时报错,怎么解决啊????????????
function openDllModal(DLLName: string; ProcName: string; vhand: THandle): THandle; stdcall;
type
TDllModalFun = function(hand: THandle): THandle; stdcall;
var
DLLHandle: THandle; //dll句柄
pDll: Pointer;
vHd:THandle;
begin
try
DLLHandle := LoadLibrary(PChar('Modal\' + DLLName));
if DLLHandle > 0 then
begin
pDll := GetProcAddress(DLLHandle, PChar(ProcName));
if pDll <> nil then
begin
try
//Result := TDllModalFun(pDll)(vhand);
vHd:=TDllModalFun(pDll)(vhand);
Result:=vHd;
except
on e: Exception do
begin
DisplayMessage('error', '执行' + ProcName + '函数出错!' + #13 + e.Message);
Exit;
end;
end;
end else
begin
DisplayMessage('error', '加载dll函数出错!');
Exit;
end;
end else
begin
DisplayMessage('error', '获取dll句柄出错!');
Exit;
end;
finally
//FreeLibrary(DLLHandle);
end;
end;
//FreeLibrary(DLLHandle); 这个屏了就不报错了这个是
procedure Tfm_TS.WMDropMessage(var Msg: TMsg; var Handled: Boolean);
var
WMD: TWMDropFiles;
vWinControl: TWinControl;
begin
case Msg.message of
WM_DROPFILES:
begin
vWinControl := FindControl(Msg.hwnd);
//ShowMessage(vWinControl.Name + '发送的消息');
end;
end; if Msg.message = WM_DROPFILES then
begin
WMD.Msg := Msg.message;
WMD.Drop := Msg.wParam;
WMD.Unused := Msg.lParam;
WMD.Result := 0;
WMDropFiles(WMD);
Handled := TRUE;
end;
end;
我报的是地址错---------------------------
Pro_dwhs
---------------------------
Access violation at address 032DB6D4. Read of address 032DB6D4.
---------------------------
确定
---------------------------
Dll就没办法处理拖动
因为我直接写procedure WMDropFiles2(var message: TMessage); message WM_DROPFILES;
根本不会触发或者在主程序中屏了 FreeLibrary(DLLHandle);都不会报错 屏 Application.OnMessage := WMDropMessage;肯定是不能的如果屏 FreeLibrary(DLLHandle);那么就没办法释放了