Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.09.04;
Скачать: CL | DM;

Вниз

Список установленных принтеров   Найти похожие ветки 

 
dolmat   (2005-08-15 13:31) [0]

Как получить список установленных принтеров
или хотя бы имя выбранного принтера после выбора в
Printsetupdialog


 
Плохиш ©   (2005-08-15 13:39) [1]

function Printer: TPrinter; + F1


 
Kazakh   (2005-08-15 14:34) [2]

Список всех установленных принтеров и установить по умолчанию.
unit MainFrm;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 StdCtrls;

type
 TMainForm = class(TForm)
   cbPrinters: TComboBox;
   lblPrinter: TLabel;
   procedure FormCreate(Sender: TObject);
   procedure cbPrintersChange(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 MainForm: TMainForm;

implementation
uses IniFiles, Printers;

{$R *.DFM}

procedure TMainForm.FormCreate(Sender: TObject);
begin
 { Copy the printer names to the combobox and set the combobox to
   show the currently selected default printer }
 cbPrinters.Items.Assign(Printer.Printers);
 cbPrinters.Text := Printer.Printers[Printer.PrinterIndex];
 // Update the label to reflect the default printer
 lblPrinter.Caption := Printer.Printers[Printer.PrinterIndex];
end;

procedure TMainForm.cbPrintersChange(Sender: TObject);
var
 IniFile: TIniFile;
 TempStr1, TempStr2: string;
 S: array[0..64] of char;
begin
 with Printer do
 begin
   // Set the new printer based on the ComboBox"s selected printer
   PrinterIndex := cbPrinters.ItemIndex;
   // Store the printer name into a temporary string
   TempStr1 := Printers[PrinterIndex];
   // Delete the unnecessary portion of the printer name
   System.Delete(TempStr1, Pos(" on ", TempStr1), Length(TempStr1));
   // Create a TIniFile class
   IniFile := TIniFile.Create("WIN.INI");
   try
     // Retrieve the device name of the selected printer
     TempStr2 := IniFile.ReadString("Devices", TempStr1, "");
     // Change the default printer to that chosen by the user
     IniFile.WriteString("windows", "device", TempStr1 + "," + TempStr2);
     // Tell all windows that the default printer changed.
     StrCopy(S, "windows");
     SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@S));
   finally
     IniFile.Free;
   end;
 end;
 // Update the label to reflect the new printer selection
 lblPrinter.Caption := Printer.Printers[Printer.PrinterIndex];
end;

end.



Страницы: 1 вся ветка

Текущий архив: 2005.09.04;
Скачать: CL | DM;

Наверх




Память: 0.45 MB
Время: 0.009 c
1-1124085580
Zaero
2005-08-15 09:59
2005.09.04
Как убрать с формы кнопки "свернуть" и "развернуть"?


4-1121384606
Ruslan_86
2005-07-15 03:43
2005.09.04
Поставить программу рядом с часами


14-1123753696
Almaz
2005-08-11 13:48
2005.09.04
База телефонов BeeLine в СПб


9-1115727375
Qwertyk
2005-05-10 16:16
2005.09.04
Пропадает сфера


1-1123239946
afanasic
2005-08-05 15:05
2005.09.04
Как сделать, чтобы окно отображалось поверх TaskBar?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский