关于改变默认打印机的问题! Printer.PrinterIndex := 0;具体那个Index,可以参考Printer.Printers属性。 解决方案 » 免费领取超大流量手机卡,每月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中怎么使用 neo tts 十万火急......Delphi 7和Delphi2010调用Dll时 兼容问题。 关于线程结束 关于控制语句的后缀表达式 为什么我的delphi7中没有TldUDPClient和TldUDPServer组件? 怎么把Query变为编辑模式呀(在线,有答案就给分) 会DelphiX的进来看下 简单的问题 delphi大华dvr改通道名字 怎样判断CheckListBox中的项目是否全被选中? 怎样表示默认打印机? 在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;