type
PHandle = ^THandle;
var
ph: PHandle;
begin
Printer.PrinterIndex := -1;
ph := Pointer(Integer(Printer)+ TObject.InstanceSize + // 访问Printer.FPrinterHandle这个私有变量
SizeOf(TCanvas)+
SizeOf(TStrings)+
SizeOf(Integer)+
SizeOf(TStrings)+
SizeOf(Integer)+
SizeOf(string)+
SizeOf(Boolean)+
SizeOf(Boolean)+
SizeOf(TPrinterCapabilities)+
SizeOf(TPrinterState)+
SizeOf(HDC)+
SizeOf(PDeviceMode)+
SizeOf(THandle));
if ph^ = 0 then
raise Exception.Create('找不到打印机');
end;