Skip to content

Latest commit

 

History

History
100 lines (79 loc) · 3.18 KB

nf-chstring-chstring-formatmessagew(uint_---).md

File metadata and controls

100 lines (79 loc) · 3.18 KB
UID title description tech.root helpviewer_keywords ms.assetid ms.date ms.keywords targetos req.assembly req.construct-type req.ddi-compliance req.dll req.header req.idl req.include-header req.irql req.kmdf-ver req.lib req.max-support req.namespace req.redist req.target-min-winverclnt req.target-min-winversvr req.target-type req.type-library req.umdf-ver req.unicode-ansi f1_keywords dev_langs topic_type api_type api_location api_name
NF:chstring.CHString.FormatMessageW(UINT,...)
CHString::FormatMessageW(UINT,...)
The CHString::FormatMessageW (Unicode) method formats a message string.
wmi
CHString::FormatMessageW
efa2f907-3a83-4508-95ef-5d40513f507e
08/10/2022
CHString::FormatMessageW
Windows
function
chstring.h
CHString::FormatMessageW
chstring/CHString::FormatMessageW
c++
apiref
COM
chstring.h
CHString::FormatMessageW

-description

[The CHString class is part of the WMI Provider Framework which is now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.]

The FormatMessageW method formats a message string.

-parameters

-param nFormatID

The string resource identifier that contains the unformatted message text.

-param ...

Argument list.

-returns

CHeap_Exception

-remarks

The FormatMessageW method requires a message definition as input. The message definition is determined by lpszFormat or from the string resource identified by nFormatID. The method copies the formatted message text to the CHString string, processing any embedded insert sequences if requested.

Each insert must have a corresponding parameter that follows the lpszFormat or nFormatID parameter. Within the message text, several escape sequences are supported for dynamically formatting the message. For a description of these escape sequences and their meanings, see the Windows FormatMessage function topic.

Note To reduce exposure to security attacks, always use a format string for FormatMessageW. For example, FormatMessageW(input) is exploitable, and FormatMessageW("%s", input) is not. Never use a user-supplied string for the format string. If your format string is stored for a purpose such as localization, ensure that the string is protected from unauthorized write access. If your function writes to a string rather than standard output, you may need to avoid using a trailing "%s" in the format string.

Examples

The following code example shows you how to use CHString::FormatMessageW.

CHString str;
int nAsked = 5;
int nAgree = 4;

str.FormatMessageW(L"%1!d! of %2!d! developers agree: Golf is %3%!", 
   nAgree, nAsked, L"Best");
assert(str == L"4 of 5 developers agree: Golf is Best!");

-see-also

CHString

CHString::Format