Declare Function lstrcpy Lib "kernel32.dll" Alias "lstrcpyA" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
lstrcpy copies the entire contents of one string into another string. Either string, instead of being a "real" string, can also be merely a pointer to a string instead. The target string must already have enough space to receive the source string's contents. The function also will copy a terminating null character into the target string.
If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.
This function is very useful for "converting" a pointer to a string into an actual string.
' Copy the source string to the target string
Dim source As String, target As String ' the two strings
Dim retval As Long ' return value
source = "Hello, world!" ' the source string to copy
target = Space(Len(source)) ' make room in target to receive the copied string
retval = lstrcpy(target, source) ' set target to equal source
Debug.Print "Source string: "; source
Debug.Print "Target string: "; target ' they should be the same....
Last Modified: December 22, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information