Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if Debugger is Attached in VB6

Tags:

debugging

vb6

I'm doing some maintenance work on one of our old applications that is written in Visual Basic 6, and for various reasons, we have a part of the code that only needs to be run if we are running the program through the VB6 IDE (i.e., the debugger is attached).

In VB.NET, you can do this by using the System.Diagnostics.Debugger.IsAttached() property, but I can't find anything similar in VB6 on Google.

Is there some easy way to figure this information out?

like image 749
bhamby Avatar asked Feb 29 '12 20:02

bhamby


1 Answers

Here is what we are using that does not have any side effects

Public Property Get InIde() As Boolean
    Debug.Assert pvSetTrue(InIde)
End Property

Private Function pvSetTrue(bValue As Boolean) As Boolean
    bValue = True
    pvSetTrue = True
End Function
like image 178
wqw Avatar answered Sep 24 '22 00:09

wqw