Index of refk


Declare Function lstrcpy Lib "kernel32.dll" Alias "lstrcpyA" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

Description & Usage

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.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

This function is very useful for "converting" a pointer to a string into an actual string.

Parameters

lpString1
String that receives the copied contents of lpString2. This could be either the string itself or a pointer to the string.
lpString2
Either an actual string to copy into lpString1 or a pointer to the string to copy into lpString1.

Example

' 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....

See Also

lstrcpyn

Category

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



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net