本文介绍了检测是否在VB6中附加了调试器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Visual Basic 6编写的一个旧应用程序中进行一些维护工作,由于各种原因,我们只有一部分代码需要通过以下方式运行: VB6 IDE(即附加了调试器)。

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).

在VB.NET中,您可以使用属性,但在Google的VB6中找不到类似的东西。

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?

推荐答案

我们正在使用的方法没有任何副作用

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

这篇关于检测是否在VB6中附加了调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:45