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一直不匹配!!!如何解决?
 

解决方案 »

  1.   

    if  SetPicture(Byte(Integer(pBitmapImage)))  then
      

  2.   

    就你的例子, 我覺得, 你修改如下試試:
    function  SetPicture(var  pBuf:  pointer):Boolean;stdcall;external  'Actpicture.dll';  
    ...
    if  SetPicture(pBitmapImage)  then
      

  3.   

    pBitmapImage  占四个字节,
    把它当作一个字节的Byte,当然会出问题啦。就算是你强制转换也会 出问题DI
      

  4.   

    我将申明改为
    function  SetPicture(var  pBuf:  pointer):Boolean;stdcall;external  'Actpicture.dll';  
    ...
    var  
       pBitmapImage  :  pByte;  
    ...
    if Boolean(SetPicture(pBitmapImage)) then
    ...
    还是不行啊!
      

  5.   

    function  SetPicture(var  pBuf:  pByte):Boolean;stdcall;external  'Actpicture.dll';  
    ...
    var  
       pBitmapImage  :  pByte;  
    ...
    if Boolean(SetPicture(pBitmapImage)) then
    ...
      

  6.   

    你的VC函数原形是什么?
      bool SetPicture(byte *pBuf);stdcall;   吗?
    那么可以这样定义
    type
      PByte=^Byte;
    function  SetPicture(pBuf:  PByte):Boolean;stdcall;external  'Actpicture.dll';
      

  7.   

    你的VC函数原形是什么?
      bool SetPicture(byte *pBuf);stdcall;   吗?
    还是
      bool SetPicture(byte **pBuf);stdcall;
      

  8.   

    VC函数原形是  bool SetPicture(byte *pBuf);stdcall; 我用 bool SetPicture(byte *pBuf);stdcall;
    但还是出不来,总是提示dll中找不到对应的程序,也不知道咋回事
      

  9.   

    type
      PByte=^Byte;
    function  SetPicture(pBuf:  PByte):Boolean;stdcall;external  'Actpicture.dll';
    是没错的。1、使用工具或写段代码看看你的SetPicture有没有引出
    2、若还不行,将SetPicture改 BOOL SetPicture(byte *pBuf);stdcall; 试试
      

  10.   

    这样改:
    function  SetPicture(var  pBuf:  Byte):Boolean;stdcall;external  'Actpicture.dll';
    改为:
    function  SetPicture(pBuf:  PByte):Boolean;stdcall;external  'Actpicture.dll';去掉var, Byte换成PByte!
    同意wengj(做了两年的软件,想换个行业)!