Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Change the windows default printer
This article has not been rated yet. After reading, feel free to leave comments and rate it.
The following code changes the default printer. Attention - this is a systemwide change and will affect other applications. Since this is discouraged, do it only if you have a really good reason.  | |  | | program dummy;
var
Device: array [0..255] of Char;
Driver: array [0..255] of Char;
Port: array [0..255] of Char;
hDeviceMode: THandle;
begin
Printer.PrinterIndex := 1;
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
StrCat(Device, ',');
StrCat(Device, Driver);
StrCat(Device, ',');
StrCat(Device, Port);
WriteProfileString('windows', 'device', Device);
StrCopy(Device, 'windows');
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, longint(@Device))
end. | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|