小弟写了一个dll 源码:
library Hook;
uses
  SysUtils,//我要是不用ShareMem,在调用loadlibrary的时候弹出个对话框 提示raised too many consecutive exceptions  如果用了将会出现另外一种错误 请往下看
  Classes,
  Windows,
  Messages,
  ApiHook in 'ApiHook.pas';
type
 Tdata=record
   hook:THandle;
   hooked:Boolean
 end;
 Pdata=^Tdata;
{$R *.res}
 var
  DllData:Pdata;
  dizhi:Cardinal;
procedure HookPro(Ncode,Lparam,Wparam:LongWord);stdcall;
begin
  if not DllData^.hooked then
   begin
     HookApi(dizhi);
     DllData^.hooked:=True;
   end;
   CallNextHookEx(dlldata^.hook,Ncode,Lparam,Wparam);
end;
function HookInstall(sWindow:LongWord;ss:DWORD):Boolean;stdcall;
var
 threadId:LongWord;
begin
  Result:=False;
  DllData^.hook:=0;
  threadId:=GetWindowThreadProcessId(sWindow,nil);
  DllData^.hook:=SetWindowsHookEx(WH_GETMESSAGE,@HookPro,HInstance,threadId);
  if DllData^.hook >0 then
   begin
     Result:=True;
   end
  else
   begin
     Exit;
   end;
end;
procedure UnHook;
begin
  UnHookApi;
  if DllData^.hooked then
   begin
     UnhookWindowsHookEx(dlldata^.hook);
   end;
end;
procedure MyDllHandle(Reason:integer);
var
fhandle:THandle;
begin
  case Reason of
   DLL_PROCESS_ATTACH:
     begin
       fhandle:=CreateFileMapping($ffffffff,nil,PAGE_READWRITE,0,$ffff,'Mydll');
       if fhandle=0 then
        begin
          if GetLastError=ERROR_ALREADY_EXISTS then
           begin
             fhandle:=OpenFileMapping(FILE_MAP_ALL_ACCESS,False,'Mydll');
              if fhandle=0 then
               begin
                 Exit;
               end;
           end
          else
            begin
              Exit;
            end;
          DllData:=MapViewOfFile(fhandle,FILE_MAP_ALL_ACCESS,0,0,0);
          if DllData=nil then
           begin
             CloseHandle(fhandle);
           end;
          
        end;
     end;
    DLL_PROCESS_DETACH:
      begin
        if Assigned(DllData) then
         begin
           UnmapViewOfFile(DllData);
           DllData:=nil;
         end;
        
      end;
  end;
end;
exports
HookInstall, UnHook, HookPro;
begin
 DllProc:=@MyDllHandle;
 MyDllHandle(DLL_PROCESS_ATTACH);
 DllData^.hooked:=False;
end.
如果在dll里加入了sharemen 我在程序里调用的代码:
这个是uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
如果在uses里加入sharemen 程序编译不过
 str:=GetCurrentDir()+'\Hook.dll';
  if not FileExists(str) then
  begin
    ShowMessage('没有这个dll');
    Exit;
  end;
  modlueHandle:=LoadLibrary(PChar(str));//它的modluehandle总是0
  ShowMessage(IntToStr(GetLastError));//他的返回错误值是126

  @InstallHook:=GetProcAddress(modlueHandle,'HookInstall');
请问 我这个应该怎么调用这个dll呀? 谢谢!