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.
' This code is licensed according to the terms and conditions listed here. ' 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....
lstrcpyn
Strings
Go back to the alphabetical Function listing.
Go back to the Reference section index.
Last Modified: December 22, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/l/lstrcpy.html