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”应该是可以验证的,为什么还会报错呢?请求牛牛们指示
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”应该是可以验证的,为什么还会报错呢?请求牛牛们指示
解决方案 »
- Tservice应用运行后为何在任务管理器中看到进程?
- Delphi 十进制转十六进制函数怎么实现,不要IntTohex,返回的是string类型,要求返回的是Byte型?
- 有个数据库问题想问一下、。
- 关于使用Midas查询oracle的问题
- ?小艾再问:为什么dbgrid显示不出查询结果?"困惑之极!再第三贴求解!"
- 各位大哥门帮帮忙呀 谢谢拉
- 如何写C/S结构的程序?????
- 用sql统计的问题
- 我也想自己做一个OICQ,但在Delphi里应该用什么控件比较好呢?
- 请教,为什么我的"添加"按钮不能用?急!!!!!
- 内存表kbmMemTable的数据怎么保存为二进制文件?
- 求助,如何后台发送鼠标点击image?
一般这样用:@DynaShow:=GetProcAddress(hInst,'ShowTest');
if Assigned(DynaShow) then DynaShow..
这样可以成功太奇怪了,
if DynaShow <> nil then 成功
if DynaShow > 0 then 成功
if Assigned(DynaShow) then 成功
我觉得这样都可以,不明白你的怎么不行
if Integer(@DynaShow)<>0 then