2012-08-06 87 views
0
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型); 錯誤是:沒有足夠的實際參數約Delphi和DLL

誰可以告訴我原因。我想我定義的功能有一些問題

回答

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;