在OpenNTF中做這件事有一個很好的例子。你可以找到它here。
事實上,它是進度條,所以你可以從那裏使用全班。
訣竅是:你添加一個停止語句的函數。您測量停止聲明之前和之後的時間。如果時間超過100毫秒,則用戶不得不點擊「繼續」,這是他在這麼短的時間內從未做過的事情。如果未啓用調試器,停止被忽略 - 無延遲...
這裏是連接openntf文章中使用的功能:
Public Function IsDebugMode() As Boolean
Dim start As Variant
start = Getthreadinfo(6) ' LSI_THREAD_TICKS
Stop
If Getthreadinfo(6) - start > 100 Then IsDebugMode = True
' If you debug the application you will not be able to press the CONTINUE-Buton
' within less then 100 milliseconds, otherwise the STOP-statement is not in function
' and you will always be quicker then 100 milliseconds
End Function
雖然評論,其實是錯誤的(100個抽動不100ms,你將不得不通過每秒鐘的滴答來獲得該值),代碼仍然可以工作,並且完全按照你的要求。
它回答我的問題(即使我得到一個不必要的停止)這是一個負擔得起的解決方案,我可能會使用timer()代替Getthreadinfo。謝謝! –