to Kevin_Lmx(繁华阅尽):谢谢。 以下这段是我在别处看的,但不知为何通不过,请指教。procedure GetDefaultPrinter; begin try Printer.Refresh; if Printer.Printers.Count=0 then raise Exception.Create('系统没有安装打印机!'); Printer.PrinterIndex:=-1;//始终使用默认打印机 if not GetPrinter(Printer.Handle,0,nil,0,nil) then raise Exception.Create('打印机没有准备好,可能没有打开电源,'+#13+#13+ '或者没有登录到网络打印机所在服务器。'); //不加上这句,则在安装了打印机但没有连接时,系统将崩溃! except raise; end; end;
以下这段是我在别处看的,但不知为何通不过,请指教。procedure GetDefaultPrinter;
begin
try
Printer.Refresh;
if Printer.Printers.Count=0 then
raise Exception.Create('系统没有安装打印机!'); Printer.PrinterIndex:=-1;//始终使用默认打印机
if not GetPrinter(Printer.Handle,0,nil,0,nil) then
raise Exception.Create('打印机没有准备好,可能没有打开电源,'+#13+#13+
'或者没有登录到网络打印机所在服务器。');
//不加上这句,则在安装了打印机但没有连接时,系统将崩溃!
except
raise;
end;
end;
uses
printers,winspool;
getprinter函数在winspool单元声明
不知何故,继续请教。谢谢。