function DefaultPrinterDevice: string;
var
Device, Driver, Port: array [0..255] of Char;
Mode: THandle;
begin
Device := '';
with Printer do
if Printers.Count > 0 then
GetPrinter(Device, Driver, Port, Mode);
Result := Device;
end;
Function
SHInvokePrinterCommand(
wnd: HWND;
uAction: UINT;
lpBuf1: PChar;
lpBuf2: PChar;
fModal: BOOL
): BOOL; stdcall; external 'shell32.dll' name 'SHInvokePrinterCommandA';
ShInvokePrinterCommand( handle, 1,
PChar(DefaultPrinterDevice), nil, true )