我写了个最简单的dll 代码如下
function Test(i:integer):integer;stdcall;
begin
Result:=i;
end;
exports
Test;编译为testdll.dll文件 拷贝到系统system32文件夹下,运行regsvr32 testdll.dll
提示   已加载testdll.dll 但没有找到DllRegisterServer 输入点。无法注册这个文件。
请问这是咋回事啊?

解决方案 »

  1.   

    如果要用regsvr32注册时要注册服务
    exports
      DllGetClassObject,
      DllCanUnloadNow,
      DllRegisterServer,
      DllUnregisterServer;
      

  2.   

    只有COM才需要注意,普通的API接口DLL不需要注册,通常也不会导出注册接口。
    顺便介绍一段注册DLL的代码:
    ================================================
    unit DLLMain;interface
    uses
       windows,sysutils;
      function DLLReg(const FileName:PChar):Boolean;export;stdcall;
      function DLLUnReg(const FileName:PChar):Boolean;export;stdcall;
    type
      DLLRegProc=function :HResult;
    implementationfunction DLLReg(const FileName:PChar):Boolean;export;stdcall;
    var
       lib: THandle;
       func:TFarProc;
       DLLRegProcL:DLLRegProc;
    begin
       Result:=false;
       if not FileExists(FileName) then exit;
       lib := LoadLibrary(PChar(FileName));
       if(lib=0) then exit;
       try
          func:=GetProcAddress(lib,'DllRegisterServer');
          if not Assigned(func) then exit;
          DLLRegProcL:=DLLRegProc(func);
          Result:=DLLRegProcL=S_OK;
       finally
          FreeLibrary(lib);
       end;
    end;
    function DLLUnReg(const FileName:PChar):Boolean;stdcall;
    var
       lib: THandle;
       func:TFarProc;
       DLLRegProcL:DLLRegProc;
    begin
       Result:=false;
       if not FileExists(FileName) then exit;
       lib := LoadLibrary(PChar(FileName));
       if(lib=0) then exit;
       try
          func:=GetProcAddress(lib,'DllUnregisterServer');
          if not Assigned(func) then exit;
          DLLRegProcL:=DLLRegProc(func);
          Result:=DLLRegProcL=S_OK;
       finally
          FreeLibrary(lib);
       end;
    end;end.