Delphi Win32 服务“所选打印机无效” 2008 64 位标准服务器上的错误

发布于 2024-10-11 02:08:42 字数 446 浏览 3 评论 0原文

我在 delphi 7 中开发了一个简单的 win 32 服务 ,它执行一些打印操作。在我们的 XP 计算机上一切正常,但在目标 Windows 2008 标准服务器 上失败。当我在 print 语句周围放置 try except 块时,会导致“所选打印机无效” 错误。

当我检查打印机对象的打印机数量并将打印机对象中可用的所有打印机写入文件时,它工作正常。仅当我尝试执行打印(在任何本地和网络打印机上)时,它才会失败。

基于使用谷歌进行的大量研究,我发现了很多使用本地帐户、网络帐户、特定帐户、LogonAsUser、ImpersonateUser、LoadUserProfile 等的建议,但没有任何效果。我还在已安装的打印机上设置了安全性,以便每个人都可以访问。

这件事真让我抓狂。非常感谢任何帮助。

谢谢

I have developed a simple win 32 service in delphi 7 which performs some print operations. All works fine on our XP machines, but fails on the target Windows 2008 standard server. When I put a try except block around the print statement, it results in the "Printer Selected is not valid" error.

When I check the Printer object for count of printers and event write out all the printers available in the Printer object to a file, it works fine. Only when I try to perform a print (on any printer local and network), it fails.

Based on lot of research using google, I found quite a few suggestions to use local acct, network acct, specific acct, LogonAsUser, ImpersonateUser, LoadUserProfile, etc, etc. but nothing is working. I have also set up security on the installed printers to be accessible to everyone.

This thing is really driving me crazy. Any help is greately appreciated.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

失去的东西太少 2024-10-18 02:08:42

这可能是由于 Vista 中引入的会话 0 隔离造成的。服务始终在会话 0 中运行,但在 XP 及更早版本中,第一个登录的用户也在会话 0 中运行,从而允许服务访问该用户的桌面(从而允许“交互式”服务)和资源(如共享和打印机) 。从 Vista 开始,用户不再在会话 0 中运行,因此服务无法再访问用户特定的资源。服务必须模拟它想要访问的用户帐户。

This is likely due to Session 0 Isolation, which was introduced in Vista. Services always run in Session 0, but in XP and earlier, the first user to log in also runs in Session 0, thus allowing services to access that user's desktop (thus allowing for "Interactive" services) and resources (like shares and printers). In Vista onwards, users never run in Session 0 anymore, so services do not have access to user-specific resources anymore. A service has to impersonate the user account it wants to access.

偷得浮生 2024-10-18 02:08:42

总是很难回答“这不起作用”的问题。但我可以推测。微软过去曾对通过服务进行打印发出过警告。我认为问题在于打印机驱动程序很少被设计为在 Windows 2008 提供的服务环境中运行。服务在隔离会话中运行,它们无法再与桌面交互。打印机驱动程序往往过于繁琐,会执行诸如提示用户出现卡纸之类的事情。或者是时候购买新的经工厂认可的碳粉盒了。这在会话 0 中效果不佳,没有人能听到它尖叫。完全无法诊断,您只是无法判断服务为何停止​​运行。

也许他们在 2008 年就确定了这一点并完全阻止了它。不知道,您可以在 serverfault.com 上找到了解这一点的人

Always hard to answer an "it doesn't work" question. But I can speculate. Microsoft has warned about printing from a service in the past. I think the problem is that printer drivers are rarely designed to run in the kind of service environment that Windows 2008 provides. Services run in an isolated session, they cannot interact with the desktop anymore. Printer drivers tend to be too chatty, doing stuff like prompting the user that there's a paper jam. Or that it is time to buy a new factory approved toner cartridge. That doesn't work well in session 0, nobody can hear it scream. Quite undiagnosable, you just can't tell why the service seized-up.

Maybe they nailed this down in 2008 and blocked it completely. No idea, you'll find the people that know this at serverfault.com

夜巴黎 2024-10-18 02:08:42

我遇到了同样的错误,谷歌完成了很多工作 http:// /www.codenewsfast.com/cnf/article//permalink.art-ng1612q9464

看来delphi 2007打印机单元:Printer.pas不是为Vista及更高版本设计的。
引用的条目提供了更改 Printer.pas 源的选项。
在vista上它解决了我的问题。

I get the same kind of error, much google work done an came on http://www.codenewsfast.com/cnf/article//permalink.art-ng1612q9464

It seems that the delphi 2007 printer unit:Printer.pas is not designed for Vista and up.
The referenced entry give the option to change the source of Printer.pas.
On vista it solved my problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文