如何在Windows服务中使用FAXCOMLib?
我实现了一个发送传真消息的程序。我使用 FAXCOMLib,当我在 Windows 窗体中调用它时它可以工作。现在我想在Windows服务中调用它,这是我的问题。
代码很简单:
FaxServer faxServer = new FaxServer();
faxServer.Connect(Environment.MachineName);
object obj = faxServer.CreateDocument("D:\\test.bmp");
FaxDoc fd = (FaxDoc)obj;
fd.FaxNumber = "123xxxxx";
fd.RecipientName = "Tester";
fd.DisplayName = "TestFax";
fd.SenderName = "Annadurai";
int i = fd.Send();
lp.Debug("Sent" + i.ToString()); // Log fax id
faxServer.Disconnect();
两种方式,代码都会返回一个 id,但在 Windows 窗体中,传真被添加到“Windows 传真和扫描”,而在 Windows 服务中 - 不是。为什么?我应该怎么做才能让它发挥作用?
我使用Windows 7。
I implemented a program for sending fax messages. I use FAXCOMLib and it works when I call it in windows forms. Now I want to call it in windows service, and this is my problem.
The code is simple:
FaxServer faxServer = new FaxServer();
faxServer.Connect(Environment.MachineName);
object obj = faxServer.CreateDocument("D:\\test.bmp");
FaxDoc fd = (FaxDoc)obj;
fd.FaxNumber = "123xxxxx";
fd.RecipientName = "Tester";
fd.DisplayName = "TestFax";
fd.SenderName = "Annadurai";
int i = fd.Send();
lp.Debug("Sent" + i.ToString()); // Log fax id
faxServer.Disconnect();
I both ways, code returns an id, but in windows forms fax is added to "Windows Fax and Scan", in windows service - NOT. Why? What should I do to make it works ?
I use Windows 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据文档,FAXCOMLIB 似乎仅适用于桌面应用程序:
适用于:仅桌面应用程序
http://msdn.microsoft.com/en-us/library/windows/desktop/ms692375(v=vs.85).aspx
仅桌面应用程序是一个糟糕的描述,因为它暗示除了网络应用程序之外的任何东西。我在控制台应用程序中运行以下代码,并且它工作正常,因此显然可以算作桌面:
According to the documentation it appears that FAXCOMLIB only works on desktop applications:
Applies to: desktop apps only
http://msdn.microsoft.com/en-us/library/windows/desktop/ms692375(v=vs.85).aspx
Desktop app only is a poor description as it implies anything but Web Apps. I have the following code running in a console app and it works fine so apparently that counts as desktop: