library dll;var
  Hooked:bool=false;
  hhkMsg:dword=0;function GetMsgProc(nCode:integer;wParam:wParam;lParam:lParam):lResult;stdcall;
begin
  if not Hooked then
  begin
    Hooked:=true;
    showmessage(inttostr(getcurrentprocessid));
  end;
  result:=CallNextHookEx(hhkMsg,nCode,wParam,lParam);
end;procedure SetHook;
begin
  if hhkMsg<>0 then exit;
  hhkMsg:=SetWindowsHookEx(WH_GETMESSAGE,@GetMsgProc,hInstance,0);
end;procedure EndHook;
begin
  if hhkMsg=0 then exit;
  UnHookWindowsHookEx(hhkMsg);
  hhkMsg:=0;
end;这样为什么不能保证一个进程只HOOK一次? Hooked不是dll的局部变量吗? HOOK一次后,Hooked为true了, 就应该不HOOK不执行showmessage了呀 
为什么会有些进程HOOK不到,而有些又执行多次showmessage的情况呢?
怎样才能保证一个进程只HOOK一次? 也就是只显示一次showmessage的信息.