Call of PB dynamic Connection Library and external Function

Source: Internet
Author: User

External functions: functions written in other languages stored in the dynamic link library.

1. External Functions

Steps for describing external functions:

1) first open the object to describe the external function;

2) In the script window, select declare from the first drop-down list box and Global External funnal or local external funnal from the second drop-down list box;

3) in the script window, enter the statements that describe the external functions;

4) Save the object;

Syntax of external functions:

{Access} function returndatatype name ({ref} datatype1 arg1 ,..., {Ref} datatypen argn}) Library "libname"

Alias for "extname"

Describes the syntax of the external process:

{Access} subroutine name ({ref} datatype1 arg1 ,..., {Ref} datatypen argn}) Library "libname"

Alias for "extname"

2. External function call example

1. Get the username information:

1.1 button Clicked:

Long ll_RTN

String ls_UserName

Long ll_BufferLen

Ll_BufferLen = MAX_LENGTH

Ls_UserName = Space (MAX_LENGTH)

// Obtain the name of the current system user

Ll_RTN = GetUserName (ls_UserName, ll_BufferLen)

If ll_RTN <> 0 Then

MessageBox ("prompt message", "the current system user name is:" + Trim (ls_UserName ))

Else

MessageBox ("prompt message", "function call failed! ")

End If

1.2 instance variable: CONSTANT Long MAX_LENGTH = 256

1.3 external functions:

FUNCTION Long GetUserName (REF String lpBuffer, REF Long nSize) LIBRARY "advapi32.dll" alias for "GetUserNameA"

2. Obtain the computer name:

2.1 button Clicked:

// Obtain the computer name

Long ll_RTN

String ls_ComputerName

Long ll_BufferLen

Ll_BufferLen = MAX_COMPUTERNAME_LENGTH + 225

Ls_ComputerName = Space (MAX_COMPUTERNAME_LENGTH + 225)

Ll_RTN = GetComputerName (ls_ComputerName, ll_BufferLen)

If ll_RTN <> 0 Then

MessageBox ("prompt message", "computer name:" + Trim (ls_ComputerName ))

Else

MessageBox ("prompt message", "function call failed! ")

End If

2.2 instance variable: CONSTANT Long MAX_COMPUTERNAME_LENGTH = 31

2.3 external functions:

FUNCTION Long GetComputerName (REF String lpBuffer, REF Long nSize) LIBRARY "kernel32" alias for "GetComputerNameA"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.