Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine at runtime when your C++ application has the visual studio debugger attached?

How do you determine at runtime whether the visual studio debugger is attached to your process. I've seen instructions for how to do this in .NET, but my process is a native C++ process. Support for detecting Just-in-time debugging would be nice but not a strict requirement.

like image 911
Jeremy Bell Avatar asked May 07 '10 14:05

Jeremy Bell


People also ask

How do I trace code in Visual Studio?

So what you can do is launch the application, then from Visual Studio click Debug > Windows > Call Stack.


2 Answers

The Win32 call IsDebuggerPresent() sounds like it ought to work.

like image 139
unwind Avatar answered Oct 05 '22 09:10

unwind


Use IsDebuggerPresent

like image 32
Nikola Smiljanić Avatar answered Oct 05 '22 08:10

Nikola Smiljanić