Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem calling external function

Status
Not open for further replies.

larry609

IS-IT--Management
Oct 11, 2010
3
US
I'm using 11.51 Desktop.

I copy in a function call from the PB docs and I get C0031: Syntax error. I've tried a number of API calls - no joy.

FUNCTION boolean GetComputerNameW(ref string cname,ref long nbuf) LIBRARY "Kernel32.dll"
string ls_compname
long ll_buf
ll_buf=25

Why is my PB unable to call an external function?

Thanks,
Larry
 
This is the proper unicode version of this:
Declaration:
function boolean GetComputerNameW(ref string lpBuffer, ref ulong nSize) library "KERNEL32.DLL"

Calling the external function
Code:
boolean	lb_rc
ulong		lul_size = 16 // MAX_COMPUTERNAME_LENGTH + 1
string 	ls_computer_name

ls_computer_name = space(lul_size)

lb_rc = GetComputerNameW( ls_computer_name, lul_size)

if not lb_rc THEN
	return ""
else
	return ls_computer_name
end if

Matt

"Nature forges everything on the anvil of time"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top