halfdream:stdcall为按C方式参数传递,去掉后一样出错 zengyfeng:照你的方法,DELPHI指出找不到相应的输出函数,DELPHI中应怎样省明 另: 按我原来的方式, if SetHook(Handle,MWM_UpdateMsg,MWM_CopyMsg,MWM_MouseMsg) then ShowMessage('OK'); 其实OK已经正常显示,应该说HOOK安装正确,出错报 Access Vialation at address 000000500 .read at address FFFFFFF 是在StdCtrls单元下面的内容里 procedure TButtonControl.WndProc(var Message: TMessage); begin case Message.Msg of WM_LBUTTONDOWN, WM_LBUTTONDBLCLK: if not (csDesigning in ComponentState) and not Focused then begin FClicksDisabled := True; Windows.SetFocus(Handle); FClicksDisabled := False; if not Focused then Exit; end; CN_COMMAND: if FClicksDisabled then Exit; end; inherited WndProc(Message); end; //在这里报错 不知什么原因,请高手指点
http://alin.heha.net/vnchooks.zipDLL的声明
#if !defined(_VNCHOOKS_DLL_)
#define _VNCHOOKS_DLL_#include <windows.h>/////////////////////////////////////////////////////////////////////////////
// Define the import/export tags#define DllImport __declspec(dllimport)
#define DllExport __declspec(dllexport)/////////////////////////////////////////////////////////////////////////////
//
// Functions used by WinVNCextern "C"
{
// DLL functions:
DllExport BOOL SetHook(
HWND hWnd,
UINT UpdateMsg,
UINT CopyMsg,
UINT MouseMsg
); // Set the hook
DllExport BOOL UnSetHook(HWND hWnd); // Remove it DllExport BOOL SetKeyboardFilterHook(BOOL activate);
// Control keyboard filtering
DllExport BOOL SetMouseFilterHook(BOOL activate);
// Control mouse filtering
}#endif // !defined(_VNCHOOKS_DLL_)
~~~~~~~\可能这儿错了。
DllExport BOOL __stdcall UnSetHook(HWND hWnd);
~~~~~~~~~
zengyfeng:照你的方法,DELPHI指出找不到相应的输出函数,DELPHI中应怎样省明
另:
按我原来的方式,
if SetHook(Handle,MWM_UpdateMsg,MWM_CopyMsg,MWM_MouseMsg) then
ShowMessage('OK');
其实OK已经正常显示,应该说HOOK安装正确,出错报
Access Vialation at address 000000500 .read at address FFFFFFF
是在StdCtrls单元下面的内容里
procedure TButtonControl.WndProc(var Message: TMessage);
begin
case Message.Msg of
WM_LBUTTONDOWN, WM_LBUTTONDBLCLK:
if not (csDesigning in ComponentState) and not Focused then
begin
FClicksDisabled := True;
Windows.SetFocus(Handle);
FClicksDisabled := False;
if not Focused then Exit;
end;
CN_COMMAND:
if FClicksDisabled then Exit;
end;
inherited WndProc(Message);
end; //在这里报错
不知什么原因,请高手指点
为什么错误出现在调用后:因为cdecl有调用者清栈,stdcall有被调者清栈,因此你用stdcall方式去调用cdecl的函数将导致堆栈多弹出了有用数据,导致访问违例。