Ver Mensaje Individual
  #1  
Antiguo 13-06-2019
Avatar de newtron
[newtron] newtron is offline
Membrillo Premium
 
Registrado: abr 2007
Ubicación: Motril, Granada
Posts: 3.462
Reputación: 21
newtron Va camino a la fama
Problema al pasar función de D2007 a Berlín

Hola a tod@s.


Tengo esta función para activar/desactivar la función "duplex" de las impresoras:


Código Delphi [-]
Function funcSetDuplex(Duplex : Boolean): Boolean;
{This procedure sets the current printer in duplex or simplex}
var
Device, Driver, Port : array[0..255] of char; {0..80 may not handle long
ports}
hDMode : THandle;
pMode, PDMode : PDevMode;
begin
  Result := False; {Initialize result to False, may be unnecessary}
  printer.GetPrinter(Device, Driver, Port, hDMode);
  if hDMode <> 0 then begin {got handle to Device Mode}
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then begin {set duplex if capable}
      if DeviceCapabilitiesA(Device, Port, DC_DUPLEX, nil, nil) = 1 then begin
        Result := True; {Printer can do Duplex}
        {DeviceCapsA returns 1 if parameter accepts or 0 if not}
        pDMode^.dmFields := pDMode^.dmFields or dm_Duplex;
        if Duplex
          then pDMode^.dmDuplex := dmDup_VERTICAL
          else pDMode^.dmDuplex := dmDup_SIMPLEX;
      end
      else Result := False; {return false if printer can't do Duplex}
      GlobalUnlock(hDMode);
    end; {end got pDMode}
  end; {end got handle to DevMode}
end;


Esto con mi Delphi 2007 va perfectamente pero estoy intentando pasarla a Delphi Berlin y me da el siguiente error al compilar:


Incompatible types: 'PAnsiChar' and 'array[0..255] or Char


señalando la variable "Device" de la linea "if DeviceCapabilitiesA(Device, Port, DC_DUPLEX, nil, nil) = 1 then begin"


Imagino que habrá que hacer alguna conversión de tipos de variable pero la verdad es que no doy con la tecla.


¿Alguien me puede iluminar?


Gracias y un saludo
__________________
Be water my friend.
Responder Con Cita