网站导航免费论文 原创论文 论文搜索 原创论文 网学软件 学术大家 资料中心 会员中心 问题解答 原创论文 论文素材 设计下载 最新论文 下载排行 论文上传 在线投稿 联系我们
返回网学首页
网学联系
最新论文 推荐专题 热门论文 素材专题
当前位置: 网学 > 编程文档 > DELPHI > 正文
Delphi中设置默认打印机
来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/12
下载{$ArticleTitle}原创论文样式

type
  TForm1 = class(TForm)
    Button1: TButton;
    ComboBox1: TComboBox;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }   
  public
    { Public declarations }
  end;

{}

procedure TForm1.FormCreate(Sender: TObject);
begin
  { tell printer to go to the default by setting
    the PrinterIndex value to -1 }
  Printer.PrinterIndex := -1;

  { make our combobox non-editable }
  ComboBox1.Style      := csDropDownList;

  { set our combobox items to the printer printers }
  ComboBox1.Items      := Printer.Printers;

  { set combobox to view the default printer
    according to printer printerindex as set above }
  ComboBox1.ItemIndex  := Printer.PrinterIndex;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  MyHandle  : THandle;
  MyDevice,
  MyDriver,
  MyPort: array [0..255] of Char;
begin
  { set printer to the selected according to the
    combobox itemendex }
  Printer.PrinterIndex := ComboBox1.ItemIndex;

  { get our printer properties }
  Printer.GetPrinter(MyDevice,
                     MyDriver,
                     MyPort,
                     MyHandle);

  { create string of exactly what WriteProfileString()
    wants to see by concat each of the above received
    character arrays }
  StrCat( MyDevice, '','');
  StrCat( MyDevice, MyDriver );
  StrCat( MyDevice, '','');
  StrCat( MyDevice, MyPort );

  { copy our new default printer into our windows ini file
    to the [WINDOWS] section under DEVICE= }
  WriteProfileString(''WINDOWS'',
                     ''DEVICE'',
                     MyDevice );

  { tell all applications that the windows ini file has
    changed, this will cause them all to recheck default
    printer }
  SendMessage(HWND_BROADCAST,
  
  • 上一篇资讯: 得到CPU速度,单位MHz
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号