具体代码 procedure SetDefaultPrinter(NewDefPrinter: string); var ResStr: array[0..255] of Char; begin StrPCopy(ResStr, NewdefPrinter); WriteProfileString('windows', 'device', ResStr); StrCopy(ResStr, 'windows'); SendMessage(HWND_BROADCAST, WM_WININICHANG…
本文主要介绍如何获取以及设置系统的默认打印机. 1.获取系统中的所有打印机 获取系统中的所有打印机可以使用EnumPrinters()函数,该函数可以枚举全部的本地.网络打印机信息.其函数原型为: BOOL WINAPI EnumPrinters( DWORD Flags, LPSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned ); 其中,参数Flags可以…
获取默认打印机: SELECT * FROM Win32_Printer WHERE Default=True 常用的几个WMI: 主板:Win32_BaseBoard http://msdn.microsoft.com/en-us/library/aa394072(VS.85).aspx CPU:  Win32_Processor  http://msdn.microsoft.com/en-us/library/aa394373(VS.85).aspx 显卡:Win32_VideoContro…
通常web技术无法设置本地计算机的默认打印机,包括用代码设置纸张大小,如果业务系统中真遇到这种需求,只能通过其它辅助手段(比如ActiveX)实现.下面这段代码,出自网上被广泛使用的"泥人张打印API"(抱歉未找到原始出处),已经用C#封装了很多关于底层打印的API方法 using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; usin…
实现如下效果: 实现方式如下: using System;using System.Drawing.Printing;using System.Runtime.InteropServices;using System.Windows.Forms; namespace PISS.View.CustomControl{ public partial class PrinterConfigMessBox : Form { #region 定义.构造.初始化 [DllImport("winspool.d…
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Med…
项目中,需要选择打印机,切换打印机.demo如下(wpf应用程序): Xaml: <Window x:Class="PrintersApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWin…
默认打印机是不是联网打印机,如果cad找不到这个打印机将会很慢才打开cad的界面(它真的不是卡死了,而是找不到...) 奇妙的是桌子至今都没有利用新建线程的方式来控制这个打印机等待,而是直接在主程序上面实现(cad公司是知道这回事的,因为我在官网有解答)..... 一种想法就是双击cad.exe的时候插入某些代码到exe前面,这个对于敲c++的人恐怕不难... 那cad.net只有在界面加载之后才能运行,那么第一次启动的时候就等一下,以至于我下面的代码能执行,并提示... 为什么需要提示就不用我…
Delphi获取默认打印机名称及端口 在前段时间写的收银系统中由于目前市场上很多电脑主板上已经没有并口,而POS机却又需要并口,所以目前需要用PCI转接卡,这个就导致不同门店使用的端口就有可能不同,这就给我们程序中弹出钱箱的指令带来一定的难度.所以就通过获取Window自带的默认,得出打印机信息. 在Windows文件下有个win.ini,里面自带默认打印机的信息.通过调用API函数Getprofilestring这个函数获取打印机信息.   在界面上拖个button,在其单击事件中写: pro…
http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece763105790245b09c0252bd7a74a2485d315d2390f07506694ea7a7d0d5d83d87f6305ac4957f7b86c65377571eb8f8dd50a8bb485582a9f5631671df65663d50edcba5154cb37e12efeae69f0caf625e7aec5a5de4320c944040a9780fb4d7467&p…