我收到了一些零星的报告,说我的应用程序(用Delphi 7编译)拒绝在某些PC上启动--它立即退出,并带有Windows错误消息:
“....exe遇到了一个问题,需要关闭。不便之处,我们深表歉意“
到目前为止,我的建议一直是安装一台默认打印机(任何打印机-甚至PDF打印机),然后问题就消失了。如何修复应用程序?我的程序只在用户按下“打印”按钮时才访问PrinterDialog控件。
发布于 2009-12-30 09:02:28
我收到了一封包含MadExcept生成的bug报告的电子邮件,其中包含了非常有用的堆栈跟踪:
exception class : EReadError
exception message : Error reading PrinterDialog.Copies: Operation not supported on selected printer.
main thread ($5d4):
0044c0a2 Classes HandleException
0044c258 Classes TReader.ReadProperty
0044bbf5 Classes TReader.ReadDataInner
0044bbd7 Classes TReader.ReadData
00450675 Classes TComponent.ReadState
0044ba51 Classes TReader.ReadComponent
0044bc69 Classes TReader.ReadDataInner
0044bba8 Classes TReader.ReadData
00450675 Classes TComponent.ReadState
004963a5 Controls TControl.ReadState
004998c9 Controls TWinControl.ReadState
004afcc9 Forms TCustomForm.ReadState
0044c9a9 Classes TReader.ReadRootComponent
00449f42 Classes TStream.ReadComponent
00446a3b Classes InternalReadComponentRes
00446bc5 Classes InitComponent
00446c56 Classes InitInheritedComponent
004af661 Forms TCustomForm.Create
004518b0 Classes StdWndProc
004b7111 Forms TApplication.CreateForm
006abe32 176 initialization造成这个问题的原因是我在设计时设置了许多TPrinterDialog属性,例如要打印页码的标志。当Delphi试图创建表单并在没有打印机的PC上设置这些属性时,就会发生错误。
解决方案是删除旧的TPrinterDialog,并将其替换为新的默认TPrinterDialog,并在安装新打印机后在运行时设置属性。
发布于 2010-01-02 12:05:48
除了崩溃语句之外,您可以“试一试”:
Try
Statement
{Statement...}
Except
Statement
{Statement...}
End; http://www.delphibasics.co.uk/RTL.asp?Name=Try
关于try/except的进一步说明
https://stackoverflow.com/questions/1979155
复制相似问题