The external API function returns garbled characters

Symptom

Calling the following function returns garbled code.

function boolean GetComputerNameA(ref string lpBuffer, ref ulong nSize) library "kernel32.dll"

 

Environment 

PowerBuilder 2017 or later

Cause

This is because the external API function is not properly declared.  

Solution

Modify the API declaration as follows to solve the problem:

Function boolean GetComputerNameA(ref string lpBuffer, ref ulong nSize) library "kernel32.dll" alias for "GetComputerNameA;Ansi"