ReportEvent:记录的消息 运行 所有行在一起
ReportEvent: Logged messages run all lines together
我注意到当使用 ReportEvent 记录多行消息时,它会丢弃所有行尾并将文本 运行 放在一起。例如,我的 MC 文件可能有:
MessageId=
Severity=Informational
SymbolicName=MSG_TEST_MSG
Language=English
Some text
Another line of text.
Last line of text.
.
事件查看器中的消息同时显示所有三行 运行。
如果我在插入字符串的文本中放入 \r\n
个序列,那些行尾会正确显示在记录的消息中。
此外,如果我使用 FormatMessageW
生成上述消息的文本字符串,则行尾会正确包含在文本中。它们似乎只有在发布到事件查看器时才会被删除。
我还没有看到任何关于行尾在任何地方被删除这一事实的参考。任何的想法?就这样吗?
谢谢。
您必须使用 %n
在邮件中强制使用“硬换行符”。
%n
Generates a hard line break when it occurs at the end of a line. This
can be used with FormatMessage to ensure that the message fits a
certain width.
"Why does FormatMessage say that %0 terminates the message without a trailing newline? Is it secretly adding newlines?" 在这种情况下可能也很有趣。
我注意到当使用 ReportEvent 记录多行消息时,它会丢弃所有行尾并将文本 运行 放在一起。例如,我的 MC 文件可能有:
MessageId=
Severity=Informational
SymbolicName=MSG_TEST_MSG
Language=English
Some text
Another line of text.
Last line of text.
.
事件查看器中的消息同时显示所有三行 运行。
如果我在插入字符串的文本中放入 \r\n
个序列,那些行尾会正确显示在记录的消息中。
此外,如果我使用 FormatMessageW
生成上述消息的文本字符串,则行尾会正确包含在文本中。它们似乎只有在发布到事件查看器时才会被删除。
我还没有看到任何关于行尾在任何地方被删除这一事实的参考。任何的想法?就这样吗?
谢谢。
您必须使用 %n
在邮件中强制使用“硬换行符”。
%n
Generates a hard line break when it occurs at the end of a line. This can be used with FormatMessage to ensure that the message fits a certain width.
"Why does FormatMessage say that %0 terminates the message without a trailing newline? Is it secretly adding newlines?" 在这种情况下可能也很有趣。