网站首页  词典首页

请输入您要查询的函数:

 

术语 wsprintf
释义 wsprintf
语法:
int wsprintf( LPTSTR lpOut,
LPCTSTR lpFmt,
...
);
wsprintf函数
wsprintf Function
The wsprintf function formats and stores a series of characters and values in a buffer. Any arguments are converted and copied to the output buffer according to the corresponding format specification in the format string. The function appends a terminating null character to the characters it writes, but the return value does not include the terminating null character in its character count.
Parameters
lpOut
[out] Pointer to a buffer to receive the formatted output. The maximum size of the buffer is 1024 bytes.
lpFmt
[in] Pointer to a null-terminated string that contains the format-control specifications. In addition to ordinary ASCII characters, a format specification for each argument appears in this string. For more information about the format specification, see the Remarks section.
...
[in] Specifies one or more optional arguments. The number and type of argument parameters depend on the corresponding format-control specifications in the lpFmt parameter.
Return Value
If the function succeeds, the return value is the number of characters stored in the output buffer, not counting the terminating null character.
If the function fails, the return value is less than the length of the expected output. To get extended error information, call GetLastError .
Remarks
Security Alert Using this function incorrectly can compromise the security of your application. The string returned in lpOut is not guaranteed to be NULL-terminated. Also, avoid the %s format -- it can lead to a buffer overrun. If an access violation occurs it causes a denial of service against your application. In the worse case, an attacker can inject executable code. Consider using one of the following alternatives: StringCbPrintf , StringCbPrintfEx , StringCbVPrintf , StringCbVPrintfEx , StringCchPrintf , StringCchPrintfEx , StringCchVPrintf , or StringCchVPrintfEx . You should review Security Considerations: Windows User Interface before continuing.
The format-control string contains format specifications that determine the output format for the arguments following the lpFmt parameter. Format specifications, discussed below, always begin with a percent sign (%). If a percent sign is followed by a character that has no meaning as a format field, the character is not formatted (for example, %% produces a single percent-sign character).
The format-control string is read from left to right. When the first format specification (if any) is encountered, it causes the value of the first argument after the format-control string to be converted and copied to the output buffer according to the format specification. The second format specification causes the second argument to be converted and copied, and so on. If there are more arguments than format specifications, the extra arguments are ignored. If there are not enough arguments for all of the format specifications, the results are undefined.
A format specification has the following form:
%[-][#][0][width][.precision]type
Each field is a single character or a number signifying a particular format option. The type characters that appear after the last optional format field determine whether the associated argument is interpreted as a character, a string, or a number. The simplest format specification contains only the percent sign and a type character (for example, %s). The optional fields control other aspects of the formatting. Following are the optional and required fields and their meanings.
FieldMeaning
–Pad the output with blanks or zeros to the right to fill the field width, justifying output to the left. If this field is omitted, the output is padded to the left, justifying it to the right.
#Prefix hexadecimal values with 0x (lowercase) or 0X (uppercase).
0Pad the output value with zeros to fill the field width. If this field is omitted, the output value is padded with blank spaces.
widthCopy the specified minimum number of characters to the output buffer. The width field is a nonnegative integer. The width specification never causes a value to be truncated; if the number of characters in the output value is greater than the specified width, or if the width field is not present, all characters of the value are printed, subject to the precision specification.
.precisionFor numbers, copy the specified minimum number of digits to the output buffer. If the number of digits in the argument is less than the specified precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds the specified precision. If the specified precision is 0 or omitted entirely, or if the period (.) appears without a number following it, the precision is set to 1.
For strings, copy the specified maximum number of characters to the output buffer.
typeOutput the corresponding argument as a character, a string, or a number. This field can be any of the following values.
ValueMeaning
cSingle character. This value is interpreted as type WCHAR if the calling application defines Unicode and as type __wchar_t otherwise.
CSingle character. This value is interpreted as type __wchar_t if the calling application defines Unicode and as type WCHAR otherwise.
dSigned decimal integer. This value is equivalent to i.
hc, hCSingle character. The wsprintf function ignores character arguments with a numeric value of zero. This value is always interpreted as type __wchar_t, even when the calling application defines Unicode.
hdSigned short integer argument.
hs, hSString. This value is always interpreted as type LPSTR, even when the calling application defines Unicode.
huUnsigned short integer.
iSigned decimal integer. This value is equivalent to d.
lc, lCSingle character. The wsprintf function ignores character arguments with a numeric value of zero. This value is always interpreted as type WCHAR, even when the calling application does not define Unicode.
ldLong signed integer. This value is equivalent to li.
liLong signed integer. This value is equivalent to ld.
ls, lSString. This value is always interpreted as type LPWSTR, even when the calling application does not define Unicode. This value is equivalent to ws.
luLong unsigned integer.
lx, lXLong unsigned hexadecimal integer in lowercase or uppercase.
pWindows 2000/XP: Pointer. The address is printed using hexadecimal.
sString. This value is interpreted as type LPWSTR when the calling application defines Unicode and as type LPSTR otherwise.
SString. This value is interpreted as type LPSTR when the calling application defines Unicode and as type LPWSTR otherwise.
uUnsigned integer argument.
x, XUnsigned hexadecimal integer in lowercase or uppercase.
Note It is important to note that wsprintf uses the C calling convention (_cdecl), rather than the standard call (_stdcall) calling convention. As a result, it is the responsibility of the calling process to pop arguments off the stack, and arguments are pushed on the stack from right to left. In C-language modules, the C compiler performs this task.
To use buffers larger than 1024 bytes, use _snwprintf. For more information, see the documentation for the C run-time library.
Example
For an example, see Reading from a Mailslot .
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as ANSI and Unicode versions.

参见
Strings 概述 ,StringCbPrintf,StringCbPrintfEx,StringCbVPrintf,StringCbVPrintfEx,StringCchPrintf,StringCchPrintfEx,StringCchVPrintf,StringCchVPrintfEx,wvsprintf
==英文原文==wsprintf Function
The wsprintf function formats and stores a series of characters and values in a buffer. Any arguments are converted and copied to the output buffer according to the corresponding format specification in the format string. The function appends a terminating null character to the characters it writes, but the return value does not include the terminating null character in its character count.
Syntax
int wsprintf( LPTSTR lpOut,
LPCTSTR lpFmt,
...
);
Parameters
lpOut
[out] Pointer to a buffer to receive the formatted output. The maximum size of the buffer is 1024 bytes.
lpFmt
[in] Pointer to a null-terminated string that contains the format-control specifications. In addition to ordinary ASCII characters, a format specification for each argument appears in this string. For more information about the format specification, see the Remarks section.
...
[in] Specifies one or more optional arguments. The number and type of argument parameters depend on the corresponding format-control specifications in the lpFmt parameter.
Return Value
If the function succeeds, the return value is the number of characters stored in the output buffer, not counting the terminating null character.
If the function fails, the return value is less than the length of the expected output. To get extended error information, call GetLastError .
Remarks
Security Alert Using this function incorrectly can compromise the security of your application. The string returned in lpOut is not guaranteed to be NULL-terminated. Also, avoid the %s format -- it can lead to a buffer overrun. If an access violation occurs it causes a denial of service against your application. In the worse case, an attacker can inject executable code. Consider using one of the following alternatives: StringCbPrintf , StringCbPrintfEx , StringCbVPrintf , StringCbVPrintfEx , StringCchPrintf , StringCchPrintfEx , StringCchVPrintf , or StringCchVPrintfEx . You should review Security Considerations: Windows User Interface before continuing.
The format-control string contains format specifications that determine the output format for the arguments following the lpFmt parameter. Format specifications, discussed below, always begin with a percent sign (%). If a percent sign is followed by a character that has no meaning as a format field, the character is not formatted (for example, %% produces a single percent-sign character).
The format-control string is read from left to right. When the first format specification (if any) is encountered, it causes the value of the first argument after the format-control string to be converted and copied to the output buffer according to the format specification. The second format specification causes the second argument to be converted and copied, and so on. If there are more arguments than format specifications, the extra arguments are ignored. If there are not enough arguments for all of the format specifications, the results are undefined.
A format specification has the following form:
%[-][#][0][width][.precision]type
Each field is a single character or a number signifying a particular format option. The type characters that appear after the last optional format field determine whether the associated argument is interpreted as a character, a string, or a number. The simplest format specification contains only the percent sign and a type character (for example, %s). The optional fields control other aspects of the formatting. Following are the optional and required fields and their meanings.
FieldMeaning
–Pad the output with blanks or zeros to the right to fill the field width, justifying output to the left. If this field is omitted, the output is padded to the left, justifying it to the right.
#Prefix hexadecimal values with 0x (lowercase) or 0X (uppercase).
0Pad the output value with zeros to fill the field width. If this field is omitted, the output value is padded with blank spaces.
widthCopy the specified minimum number of characters to the output buffer. The width field is a nonnegative integer. The width specification never causes a value to be truncated; if the number of characters in the output value is greater than the specified width, or if the width field is not present, all characters of the value are printed, subject to the precision specification.
.precisionFor numbers, copy the specified minimum number of digits to the output buffer. If the number of digits in the argument is less than the specified precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds the specified precision. If the specified precision is 0 or omitted entirely, or if the period (.) appears without a number following it, the precision is set to 1.
For strings, copy the specified maximum number of characters to the output buffer.
typeOutput the corresponding argument as a character, a string, or a number. This field can be any of the following values.
ValueMeaning
cSingle character. This value is interpreted as type WCHAR if the calling application defines Unicode and as type __wchar_t otherwise.
CSingle character. This value is interpreted as type __wchar_t if the calling application defines Unicode and as type WCHAR otherwise.
dSigned decimal integer. This value is equivalent to i.
hc, hCSingle character. The wsprintf function ignores character arguments with a numeric value of zero. This value is always interpreted as type __wchar_t, even when the calling application defines Unicode.
hdSigned short integer argument.
hs, hSString. This value is always interpreted as type LPSTR, even when the calling application defines Unicode.
huUnsigned short integer.
iSigned decimal integer. This value is equivalent to d.
lc, lCSingle character. The wsprintf function ignores character arguments with a numeric value of zero. This value is always interpreted as type WCHAR, even when the calling application does not define Unicode.
ldLong signed integer. This value is equivalent to li.
liLong signed integer. This value is equivalent to ld.
ls, lSString. This value is always interpreted as type LPWSTR, even when the calling application does not define Unicode. This value is equivalent to ws.
luLong unsigned integer.
lx, lXLong unsigned hexadecimal integer in lowercase or uppercase.
pWindows 2000/XP: Pointer. The address is printed using hexadecimal.
sString. This value is interpreted as type LPWSTR when the calling application defines Unicode and as type LPSTR otherwise.
SString. This value is interpreted as type LPSTR when the calling application defines Unicode and as type LPWSTR otherwise.
uUnsigned integer argument.
x, XUnsigned hexadecimal integer in lowercase or uppercase.
Note It is important to note that wsprintf uses the C calling convention (_cdecl), rather than the standard call (_stdcall) calling convention. As a result, it is the responsibility of the calling process to pop arguments off the stack, and arguments are pushed on the stack from right to left. In C-language modules, the C compiler performs this task.
To use buffers larger than 1024 bytes, use _snwprintf. For more information, see the documentation for the C run-time library.
Example
For an example, see Reading from a Mailslot .
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as ANSI and Unicode versions.
See Also
Strings Overview , StringCbPrintf , StringCbPrintfEx , StringCbVPrintf , StringCbVPrintfEx , StringCchPrintf , StringCchPrintfEx , StringCchVPrintf , StringCchVPrintfEx , wvsprintf
==原始网址==http://msdn.microsoft.com/en-us/library/ms647550(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 11:24:01