Ir para conteúdo
Fórum Script Brasil
  • 0

Alterar A Impressora Padrão Do Windows (RESOLVIDO)


Guest Danilo Bruneli

Pergunta

Guest Danilo Bruneli

oi, eu precisa alterar a impressora padrão do windows via delphi, algume saberia me imformar se tem jeito de fzer isso.

se tiver alguém sabe como??!!

obrigado

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

você pode mudar sim...

peguei esse código a algum tempo no Dicas e truques Delphi.

Pegar o Nome da Impressora...

function GetDefaultPrinterName : string;
//
// Retorna o nome da impressora padrão do Windows
//
begin
if(Printer.PrinterIndex >= 0)then
  begin
  Result := Printer.Printers[Printer.PrinterIndex];
  end
else
  begin
  Result := 'Nenhuma impressora Padrão foi detectada';
  end;
end;
  
Mudar a impressora padrão pelo Nome.
procedure SetDefaultPrinter(PrinterName: String);
var
  I: Integer;
  Device : PChar;
  Driver : Pchar;
  Port : Pchar;
  HdeviceMode: Thandle;
  aPrinter : TPrinter;
begin
  Printer.PrinterIndex := -1;
  getmem(Device, 255);
  getmem(Driver, 255);
  getmem(Port, 255); 
  aPrinter := TPrinter.create;
  for I := 0 to Printer.printers.Count-1 do
  begin
  if Printer.printers[i] = PrinterName then
  begin
  aprinter.printerindex := i;
  aPrinter.getprinter
  (device, driver, port, HdeviceMode);
  StrCat(Device, ',');
  StrCat(Device, Driver );
  StrCat(Device, Port );
  WriteProfileString('windows', 'device', Device);
  StrCopy( Device, 'windows' );
  SendMessage(HWND_BROADCAST, WM_WININICHANGE,
  0, Longint(@Device));
  end;
  end;
  Freemem(Device, 255);
  Freemem(Driver, 255);
  Freemem(Port, 255);
  aPrinter.Free;
end; 

Espero q lhe ajude!!!

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...