W
wei2003
Unregistered / Unconfirmed
GUEST, unregistred user!
请教一个问题,我有以下代码有点问题。本来我要返回一个整型值,但总报这个错,[Error] myfunction.pas(1806): Incompatible types: 'Integer'end 'TPaperNo'result:=pPapernos^[numPaperformats];
就是这句有问题,我定义pPapernos是个整型的,不太明白请赐教;
function GetPaperno:integer;
type
TPaperNo = array[0..63] of integer;
TPapernoArray = array[1..256] of TPaperNo;
FPapernoArray = ^TPapernoArray;
var
i, numPaperformats: Integer;
printername:string;
pPapernos: FPaperNoArray;
PrinterHandle: THandle;
// p_names: array[0..255] of char;
Device: array[0..255] of char;
Driver: array[0..255] of char;
Port: array[0..255] of char;
hDMode: THandle;
PDMode: PDEVMODE;
asize:integer;
begin
printername:=printer.Printers[printer.PrinterIndex];
OpenPrinter(PChar(PrinterName), PrinterHandle, nil);
Printer.GetPrinter(Device, Driver, Port, hDMode);
pDMode := GlobalLock(hDMode);
numPaperformats :=WinSpool.DeviceCapabilities(PChar(PrinterName), 'LPT1', DC_PAPERS, nil, nil);
if numPaperformats > 0 then
begin
GetMem(pPapernos,numPaperformats * Sizeof(pPapernos));
// new(pPapernos);
try
WinSpool.DeviceCapabilities(PChar(PrinterName), 'LPT1', DC_PAPERS,pchar(pPapernos), nil);
result:=pPapernos^[numPaperformats];
finally
FreeMem(pPapernos);
end;
end;
end;
就是这句有问题,我定义pPapernos是个整型的,不太明白请赐教;
function GetPaperno:integer;
type
TPaperNo = array[0..63] of integer;
TPapernoArray = array[1..256] of TPaperNo;
FPapernoArray = ^TPapernoArray;
var
i, numPaperformats: Integer;
printername:string;
pPapernos: FPaperNoArray;
PrinterHandle: THandle;
// p_names: array[0..255] of char;
Device: array[0..255] of char;
Driver: array[0..255] of char;
Port: array[0..255] of char;
hDMode: THandle;
PDMode: PDEVMODE;
asize:integer;
begin
printername:=printer.Printers[printer.PrinterIndex];
OpenPrinter(PChar(PrinterName), PrinterHandle, nil);
Printer.GetPrinter(Device, Driver, Port, hDMode);
pDMode := GlobalLock(hDMode);
numPaperformats :=WinSpool.DeviceCapabilities(PChar(PrinterName), 'LPT1', DC_PAPERS, nil, nil);
if numPaperformats > 0 then
begin
GetMem(pPapernos,numPaperformats * Sizeof(pPapernos));
// new(pPapernos);
try
WinSpool.DeviceCapabilities(PChar(PrinterName), 'LPT1', DC_PAPERS,pchar(pPapernos), nil);
result:=pPapernos^[numPaperformats];
finally
FreeMem(pPapernos);
end;
end;
end;