procedure TForm1.Button1Click(Sender: TObject);
begin
hInst:=LoadLibrary('dll\ShowMe.dll');
  if hInst>0 then
  try
  begin
   DynaShow:=GetProcAddress(hInst,'ShowTest');
    //if DynaShow<>nil then  {失败}
    //if DynaShow<>0 then    {失败}
    if DynaShow<>null then   {成功}

     DynaShow
    else
    begin
     MessageBox(handle,'函数加载失败!','警告',64);
      exit;
    end;
  end;
  finally
   FreeLibrary(hInst);
  end
  else
  begin
   MessageBox(Handle,'DLL加载失败!','警告',64);
   exit;
  end;end;
红字部分前两种会报“Incompatible types”错误,第三种就可以编译成功。
据小菜得知:在Delphi中null是函数,是验证宏是否存在的一个函数,nil是空类型指针,0就是整数0了。
根据追查GetProcAddress()函数返回值是FARPROC,而在Windows单元中FARPROC定义为Pointer类型,即FARPROC = Pointer,一次推理“DynaShow<>null”应该是可以验证的,为什么还会报错呢?请求牛牛们指示 

解决方案 »

  1.   

    http://msdn.microsoft.com/en-us/library/ms683212(v=vs.85).aspxIf the function fails, the return value is NULL. To get extended error information, call GetLastError.
    一般这样用:@DynaShow:=GetProcAddress(hInst,'ShowTest');
    if Assigned(DynaShow) then DynaShow..
      

  2.   

    if DynaShow<>null then
    这样可以成功太奇怪了,
    if DynaShow <> nil then 成功
    if DynaShow > 0 then 成功
    if Assigned(DynaShow) then 成功 
    我觉得这样都可以,不明白你的怎么不行
      

  3.   

     NULL 是字符串为空 NIL 是指针为空     NULL 是无值无类型   NIL 是空指针型 
      

  4.   

    DynaShow 应该是一个声明的一个动态链接文件内的函数!
      

  5.   

    這要看DynaShow的類型而定。。
      

  6.   

    DynaShow 是一个过程。DynaShow:=Procedure ;stdcall;
      

  7.   

    if Pointer(@DynaShow)<>nil then 
    if Integer(@DynaShow)<>0 then