⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 设置默认打印机.txt

📁 大量Delphi开发资料
💻 TXT
字号:
Use this on form create (or whatever)...


  ComboBox1.Items := Printer.Printers; {populates ComboBox}

  ComboBox1.ItemIndex := Printer.PrinterIndex; {sets display to current

printer}


then, assuming you have a Button5...


procedure TForm1.Button5Click(Sender: TObject);

var

  Device: array[0..255] of Char;

  Driver: array[0..255] of char;

  Port: array[0..255] of char;

  s : array[0..255] of Char;

  hDeviceMode: THandle;

begin

  Printer.PrinterIndex := ComboBox1.ItemIndex;

  Printer.GetPrinter (Device, Driver, Port, hDeviceMode);

  StrCopy (s, Device);

  StrCat (s, ',');

  StrCat (s, Driver);

  StrCat (s, ',');

  StrCat (s, Port);

  WriteProfileString ('windows', 'device', s);

  StrCopy (s, 'windows');

  SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@s));

end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -