如何从作为服务运行的应用程序中编写文件 [英] How do I write for a file from my application running as a service

查看:62
本文介绍了如何从作为服务运行的应用程序中编写文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将我的应用程序作为控制台应用程序运行时,我可以顺利登录到文件但是如果我将其转换为作为服务运行,我的文件写入会失败似乎。



我正在用c / c ++编写使用visual studio

解决方案

请参阅barneyman对问题的评论;这是非常合理的。



而不是直接写入文件,更好地利用 Windows事件日志的可靠性和灵活性。请从这里开始: https://msdn.microsoft。 com / zh-CN / library / windows / desktop / aa385780%28v = vs.85%29.aspx [ ^ ]。



-SA

I have no trouble logging to a file when running my app as a console app but if I convert it to run as a service my file writes fails it seems.

I'm writing in c/c++ using visual studio

解决方案

Please see the comment to the question by barneyman; it is very reasonable.

Instead of writing directly to a file, better utilize reliability and flexibility of Windows Event Log. Please start here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa385780%28v=vs.85%29.aspx[^].

—SA


这篇关于如何从作为服务运行的应用程序中编写文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆