1. Erick Siliezar
  2. PowerBuilder
  3. Thursday, 27 August 2020 00:53 AM UTC

Hi Everyone

   I need to implement in my PB 2019 R2 if there is a debugger reviewing my application. I read about IsDebuggerPresent from the windows API.

Can you please help on how I need to declare that function in PB2019.

I suppose i need to declare something like this: 

FUNCTION boolean IsDebuggerPresent () LIBRARY "KERNEL32.DLL" alias for "IsDebuggerPresent;Ansi"

 

 

MDI Event: Active

  Boolean lb_debuggerDetected = IsDebuggerPresent()

  if lb_debuggerDetected then 

    //Debugger detected do something

  End if

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 27 August 2020 02:12 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi, Erick -

You should not include the "ALIAS FOR" clause in the external function declaration, as there is no character/string information being passed in or out of this particular WinAPI function. Even if there was, you would likely want to pass the character/string information in Unicode, not ANSI, since both PB and Windows use Unicode.

Also, in your prototype event script, you probably do not want to code the WinAPI function call in the declaration of the Boolean variable, as the PB compiler will call the function during compilation and initialize the Boolean with that compile-time result - so you would always get the same result.

Regards, John

Comment
There are no comments made yet.
Erick Siliezar Accepted Answer Pending Moderation
  1. Thursday, 27 August 2020 14:41 PM UTC
  2. PowerBuilder
  3. # 1

Thanks John, so following your recommendation my script should be like this

 

FUNCTION boolean IsDebuggerPresent () LIBRARY "KERNEL32.DLL"

MDI Event: Active

  Boolean lb_debuggerDetected = False

  lb_debuggerDetected = IsDebuggerPresent()

  if lb_debuggerDetected then 

    //Debugger detected do something

  End if

Comment
  1. John Fauss
  2. Thursday, 27 August 2020 15:03 PM UTC
Your changes look fine, Erick.If you want to simplify it a little, you can eliminate the boolean variable and invoke the WinAPI function in the IF statement ("if IsDebuggerPresent() then..."): One minor technicality: The window event name is "Activate", not "Active". Good luck!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.