Search This Blog

Thursday, February 16, 2017

visual studio - Attaching the debugger to a process C++

In case you need to attached debugger into your debug program.
the next easy trick - will do it for you - if you will start your program with F1.
without F1 - it will not wait for  a debugger
very helpful !!

#ifdef _DEBUG
if ( ::GetAsyncKeyState( VK_F1 ) )
{
    while ( !::IsDebuggerPresent() )
        ::Sleep( 100 );
    ::DebugBreak();
}
#endif