DelphiFAQ Home Search:
General :: Windows :: Programming :: Windows with Delphi :: Windows Forms
Code snippets, Q+A around the Windows user interface. From a Delphi perspective, but usually applicable to other languages.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Change the windows default printer

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;
 
 // sample code by Peter Below

 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; {select printer to make default}
   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!
Generated 4:04:49 on Oct 22, 2017