简体   繁体   English

Visual C ++-找出是否由调试器启动

[英]Visual C++ - Find out if started by debugger

I'd like to use 我想用

AllocConsole();

or 要么

AttachConsole(ATTACH_PARENT_PROCESS);

depending on if the program was run within visual studio. 取决于程序是否在Visual Studio中运行。 AttachConsole will not print output to any of the windows like "output". AttachConsole不会将输出打印到任何窗口,例如“输出”。 So I'd like to use AllocConsole instead so I get a console window at least. 因此,我想改用AllocConsole,以便至少获得一个控制台窗口。

I found solutions for C# but not for C++ NOT using .NET. 我找到了针对C#的解决方案,但未找到未使用.NET的C ++解决方案。

Thanks for answers. 感谢您的回答。 I'd appreciate other ways for logging program stuff except writing to files, too :-) 除了记录文件以外,我也希望通过其他方式记录程序内容:-)

Kai

如果要记录“东西”,以便它在调试器中可见(如果存在),则可能要使用OutputDebugString

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM