DLL Example: Passing String Parameters by Value

When you pass a variable to a function by value, a copy of the variable's value is passed. The function can change the copied value of the passed variable but it cannot modify the original value of the variable within the calling program.

The example below shows how to pass two string VAL parameters. It calls the lstrcmpi function, which was exported from the Windows API's Kernel32.dll and which compares two character strings. ATEasy converts the string to ASCIIZ (null terminated) as required by the Windows API.

sString100="xyz"

sString100[3]='a'

! right now the string has xyza but has a length of 3

! ATEasy creates A temp null terminated

! of string len 3 and xyz (a is excluded)

if lstrcmpi(sString100, "xyz")<>0 then

TestStatus=Fail

endif

if sString100[3]<>'a'

TestStatus=Pass

endif