网站首页  词典首页

请输入您要查询的函数:

 

术语 lstrcpy
释义 lstrcpy
语法:
LPTSTR lstrcpy( LPTSTR lpString1,
LPTSTR lpString2
);
lstrcpy函数
这个函数拷贝到一个字符串缓冲区。
To copy a specified number of characters, use the lstrcpyn function.
参数
lpString1
[out]指向接收缓冲区的字符串的内容指出的lpString2参数。该缓冲区必须足够大,以包含字符串,包括终止空字符。
lpString2
[in]指向空终止字符串被复制。
返回值
如果函数成功,返回值是对缓冲区的指针。
如果函数失败,返回值为NULL和lpString1不得空终止。
备注
安全警告:
使用此功能不当,可能会损害您的应用程序的安全。此函数使用结构化异常处理(SEH)捕获的访问冲突和其他错误。当这个函数捕捉SEH的错误,则返回空不空结束的字符串,而没有通知错误的来电。调用方没有把握地说,没有足够的空间是错误的条件。
lpString1必须大到足以容纳lpString2和闭幕'\\ 0',否则可能会出现缓冲区溢出。
缓冲区溢出的情况是,在许多应用安全问题的原因,可引起拒绝服务攻击的应用程序对拒绝,如果发生访问冲突。在最坏的情况下,缓冲区溢出可能允许攻击者注入到可执行代码的过程中,特别是如果lpString1是一个基于堆栈的缓冲区。
考虑使用StringCchCopy代替;使用任何StringCchCopy(缓冲区,钢骨混凝土,sizeof(缓冲区)/ sizeof(缓冲区[0]);,明知不可缓冲区指针或使用StringCchCopy(缓冲,钢骨混凝土,ARRAYSIZE(缓冲区),意识到,当复制到一个指针,调用者负责在指向的内存大小的字符传递。
审查安全方面的考虑:Windows用户界面,然后继续。
有了一个双字节字符集(DBCS)系统的版本,这个功能可以用来复制DBCS字符串。
该lstrcpy函数有一个未定义的行为,如果源和目标缓冲区重叠。
在Windows 95/98/Me:lstrcpyW是支持的Unicode(MSLU)微软层。虽然W版已经在Windows 98/Me中存在,它包括给予更多的一致行为在所有的Windows操作系统。要使用此,您必须将某些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98/Me系统。
例如
有关示例,请参阅更改环境变量。
功能信息
最低DLL版本 kernel32.dll
在Winbase.h HeaderDeclared,头文件:winuser.h
import libraryKernel32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为ANSI和Unicode版本。
参见
Strings 概述 ,StringCbCopy,StringCbCopyEx,StringCbCopyN,StringCbCopyNEx,StringCchCopy,StringCchCopyEx,StringCchCopyN,StringCchCopyNEx,lstrcat,lstrcmp,lstrcmpi,lstrlen
==英文原文==lstrcpy Function
This function copies a string to a buffer.
To copy a specified number of characters, use the lstrcpyn function.
Syntax
LPTSTR lstrcpy( LPTSTR lpString1,
LPTSTR lpString2
);
Parameters
lpString1
[out] Pointer to a buffer to receive the contents of the string pointed to by the lpString2 parameter. The buffer must be large enough to contain the string, including the terminating null character.
lpString2
[in] Pointer to the null-terminated string to be copied.
Return Value
If the function succeeds, the return value is a pointer to the buffer.
If the function fails, the return value is NULL and lpString1 may not be null-terminated.
Remarks
Security Alert
Using this function incorrectly can compromise the security of your application. This function uses structured exception handling (SEH) to catch access violations and other errors. When this function catches SEH errors, it returns NULL without null-terminating the string and without notifying the caller of the error. The caller is not safe to assume that insufficient space is the error condition.
lpString1 must be large enough to hold lpString2 and the closing '\\0', otherwise a buffer overrun may occur.
Buffer overflow situations are the cause of many security problems in applications and can cause a denial of service attack against the application if an access violation occurs. In the worst case, a buffer overrun may allow an attacker to inject executable code into your process, especially if lpString1 is a stack-based buffer.
Consider using StringCchCopy instead; use either StringCchCopy(buffer, src, sizeof(buffer)/sizeof(buffer[0]);, being aware that buffer must not be a pointer or use StringCchCopy(buffer, src, ARRAYSIZE(buffer);, being aware that, when copying to a pointer, the caller is responsible for passing in the size of the pointed-to memory in characters.
Review Security Considerations: Windows User Interface before continuing.
With a double-byte character set (DBCS) version of the system, this function can be used to copy a DBCS string.
The lstrcpy function has an undefined behavior if source and destination buffers overlap.
Windows 95/98/Me: lstrcpyW is supported by the Microsoft Layer for Unicode (MSLU). Although the W version already exists on Windows 98/Me, it is included to give more consistent behavior across all Windows operating systems. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems .
Example
For an example, see Changing Environment Variables .
Function Information
Minimum DLL Versionkernel32.dll
HeaderDeclared in Winbase.h, include Windows.h
Import libraryKernel32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as ANSI and Unicode versions.
See Also
Strings Overview , StringCbCopy , StringCbCopyEx , StringCbCopyN , StringCbCopyNEx , StringCchCopy , StringCchCopyEx , StringCchCopyN , StringCchCopyNEx , lstrcat , lstrcmp , lstrcmpi , lstrlen
==原始网址==http://msdn.microsoft.com/en-us/library/ms647490(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 9:19:02