请问如何设置默认的打印机?谢谢!在线~~~~~~~~~~

klbs53 2003-04-18 02:09:15
预览的时候,点打印设置
错误提示:
没有设置默认的打印机

delphi 6
...全文
58 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
klbs53 2003-04-18
  • 打赏
  • 举报
回复
哦!
谢谢!
WWWWA 2003-04-18
  • 打赏
  • 举报
回复
从控制面板->打印机->添加、设置打印机,如有打印机,设置为
默认。
u2m 2003-04-18
  • 打赏
  • 举报
回复
以下是我收集的资料,改变默认打印机
procedure TForm1.Button1Click(Sender: TObject);
var
WinIni : TIniFile;
WinIniFileName : array[0..MAX_PATH] of char;
s : array[0..64] of char;

begin
GetWindowsDirectory(WinIniFileName, sizeof(WinIniFileName));
StrCat(WinIniFileName, '\win.ini');
WinIni := TIniFile.Create(WinIniFileName);
try
WinIni.WriteString('windows',
'device',
'HP LaserJet Series II,HPPCL,LPT1:');
finally
WinIni.Free;
end;

StrCopy(S, 'windows');
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@S));
end;

u2m 2003-04-18
  • 打赏
  • 举报
回复
This grabs the selected printer in a ComboBox and makes it the default
printer.

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;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧