title: Is IsDebuggerPresent() function a safe method to stop a process from being debugged?
body: <p>I want not to let my program debugged . I have a second thread that repeatedly checks whether a debugger is attached or not :</p>
  
  <pre><code>while(1){
      BOOL isDebugged = IsDebuggerPresent();
      if(isDebugged){
            //exit from my app
      }
      //and then check CheckRemoteDebuggerPresent()
  }
  </code></pre>
  
  <p>I want to know whether this method is secure or not? Can someone debug my app even with this protection? Is there better way ?</p>
  
  <p><strong>Edit :</strong><br>
  Actually I have a hardware security token. I want to protect my app from being copied . But I've heard that a simple true/false checking using the token will be broken by debugging the app</p>