关于delphi和dll

时间:2012-08-06 01:40:55

标签: delphi delphi-7

function:BOOL   IO_GetPageDimension(VOID   *p,   long   *imgwide,   long   *imghigh);

Parameters
p
[in]   Pointer   to   structure   'set_attribute ';
imgwide
[out]   Syscan   scanner   return   accepting   the   scan   width;
imghigh
[out]   Syscan   scanner   return   accepting   the   scan   height;

I defined the following code:
type
set_attribute = Record
  scan_mode:shortint;
  resolution:smallint;          
  brightness:shortint;          
  contrast:shortint;            
  gamma:shortint;               
  highlight:smallint;           
  shadow:smallint;              
  .......
end;

function IO_GetPageDimension(p: set_attribute; imgwide: Longint; imghigh:     Longint):Boolean;stdcall;external 'A8100.dll';
call the following code in form
begin
  p.highlight:= p.scan_mode:= 4;
  p.resolution:=300;        
  p.brightness:= 100;           
  p.contrast:= 80;          
  p.gamma:= 80;200;         
  p.shadow:= 200;           
  IO_GetPageDimension(p: set_attribute; imgwide: Longint; imghigh: Longint);
end;

但该行出错:IO_GetPageDimension(p:set_attribute; imgwide:Longint; imghigh:Longint); 错误是:实际参数不够

谁能告诉我原因。我想我定义的函数有一些问题

1 个答案:

答案 0 :(得分:2)

您的代码存在一些重大问题。 :-)这应该让你去。

type
  TSet_Attribute = Record
    scan_mode:shortint;
    resolution:smallint;          
    brightness:shortint;          
    contrast:shortint;            
    gamma:shortint;               
    highlight:smallint;           
    shadow:smallint;              
    // remaining declarations here
  end;

function IO_GetPageDimension(const Set_Attribute: TSet_Attribute; 
  var imgwide: LongInt; 
  var imghigh: Longint); BOOL; stdcall; external `A8100.dll`;


var
  SA: TSet_Attribute;
  ImageWidth, ImageHeight: Longint;
begin
  SA.highlight:= 4;  // Whatever value - your code had none
  SA.scan_mode:= 4;
  SA.resolution:=300;        
  SA.brightness:= 100;           
  SA.contrast:= 80;          
  SA.gamma:= 80;200;         
  SA.shadow:= 200;           
  if IO_GetPageDimension(SA, ImageWidth, ImageHeight) then
    // Do whatever with ImageWidth, ImageHeight
end;