怎样用程序实现设置默认打印机 Printer.PrinterIndex := 0; // 1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 2k系统中可以这样的,不知道98是不是可以!在窗体中加入combobox和两个button你自己TRY!我测试通过!procedure TForm1.Button1Click(Sender: TObject);begin ComboBox1.Items := Printer.Printers; {populates ComboBox} ComboBox1.ItemIndex := Printer.PrinterIndex; {sets display to current printer}end;procedure TForm1.Button2Click(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; delphi通过jni得到java句柄 问题进不去了,结不了贴,怎么办? 这个问题有人遇到过吗?程序发布的问题. 大家一起讨论一下,如何用对EXCEL的数据操作的结果进行分析。 大家说说CSDN都有哪些缺点,为什么人气这么差,根本没有高手过来,提个问题几天没人应。 我们还有必要守住这片田地吗? 用ADODataset1查询的结果<1时就报错! 如何DATAGRID 单元格校验,和更新扑获错误 关于用QUERY 进行数据添加的问题! delphi三层中怎么保存图片到sqlserver数据库 一个很幼稚的问题 在Win2000系统下,用程序怎样设置默认打印机。 怎样用程序实现设置默认打印机
在窗体中加入combobox和两个button
你自己TRY!
我测试通过!procedure TForm1.Button1Click(Sender: TObject);
begin
ComboBox1.Items := Printer.Printers; {populates ComboBox}
ComboBox1.ItemIndex := Printer.PrinterIndex; {sets display to current printer}
end;procedure TForm1.Button2Click(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;