我确实找到了这段代码片段,但在调试时它并没有返回true:
[DllImport("kernel32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
internal static extern bool IsDebuggerPresent();
Run Code Online (Sandbox Code Playgroud)
你标记了你的问题,C#所以我在说"但是当我调试时它没有返回真实",你实际上在谈论托管调试.
该IsDebuggerPresent()函数检查是否存在本机调试器.在您的情况下,您应该使用System.Diagnostics.Debugger.IsAttached检查是否存在(托管)调试器.
有关调试器API的更多信息,另请参阅此博客文章.
| 归档时间: |
|
| 查看次数: |
2665 次 |
| 最近记录: |