VC中写的 Actpicture.dll 在delphi中调用。
pBuf为指向byte的指针。
function SetPicture(var pBuf: Byte):Boolean;stdcall;external 'Actpicture.dll';
...
var
pBitmapHeader: pBitmapInfo;
pBitmapImage : Pointer;
HeaderSize : DWORD;
ImageSize : DWORD;
begin
GetDIBSizes(AmmeterBmp.Handle, HeaderSize, ImageSize);
GetMem(pBitmapImage, ImageSize);
try
if SetPicture(pBitmapImage)) then //括号内类型不匹配
begin
showmessage('加载图片成功!')
end
else begin
showmessage('加载图片失败!');
end;
finally
FreeMem(pBitmapImage);
end; ==================== pBitmapImage的pointer 与 byte一直不匹配!!!如何解决?
pBuf为指向byte的指针。
function SetPicture(var pBuf: Byte):Boolean;stdcall;external 'Actpicture.dll';
...
var
pBitmapHeader: pBitmapInfo;
pBitmapImage : Pointer;
HeaderSize : DWORD;
ImageSize : DWORD;
begin
GetDIBSizes(AmmeterBmp.Handle, HeaderSize, ImageSize);
GetMem(pBitmapImage, ImageSize);
try
if SetPicture(pBitmapImage)) then //括号内类型不匹配
begin
showmessage('加载图片成功!')
end
else begin
showmessage('加载图片失败!');
end;
finally
FreeMem(pBitmapImage);
end; ==================== pBitmapImage的pointer 与 byte一直不匹配!!!如何解决?
function SetPicture(var pBuf: pointer):Boolean;stdcall;external 'Actpicture.dll';
...
if SetPicture(pBitmapImage) then
把它当作一个字节的Byte,当然会出问题啦。就算是你强制转换也会 出问题DI
function SetPicture(var pBuf: pointer):Boolean;stdcall;external 'Actpicture.dll';
...
var
pBitmapImage : pByte;
...
if Boolean(SetPicture(pBitmapImage)) then
...
还是不行啊!
...
var
pBitmapImage : pByte;
...
if Boolean(SetPicture(pBitmapImage)) then
...
bool SetPicture(byte *pBuf);stdcall; 吗?
那么可以这样定义
type
PByte=^Byte;
function SetPicture(pBuf: PByte):Boolean;stdcall;external 'Actpicture.dll';
bool SetPicture(byte *pBuf);stdcall; 吗?
还是
bool SetPicture(byte **pBuf);stdcall;
但还是出不来,总是提示dll中找不到对应的程序,也不知道咋回事
PByte=^Byte;
function SetPicture(pBuf: PByte):Boolean;stdcall;external 'Actpicture.dll';
是没错的。1、使用工具或写段代码看看你的SetPicture有没有引出
2、若还不行,将SetPicture改 BOOL SetPicture(byte *pBuf);stdcall; 试试
function SetPicture(var pBuf: Byte):Boolean;stdcall;external 'Actpicture.dll';
改为:
function SetPicture(pBuf: PByte):Boolean;stdcall;external 'Actpicture.dll';去掉var, Byte换成PByte!
同意wengj(做了两年的软件,想换个行业)!