没有:
如何使用FormatMessage()
获取错误文本HRESULT
?
HRESULT hresult = application.CreateInstance("Excel.Application");
if (FAILED(hresult))
{
// what should i put here to obtain a human-readable
// description of the error?
exit (hresult);
}
Run Code Online (Sandbox Code Playgroud) 我正在运行它来测试FormatMessage:
LPVOID lpMsgBuf;
errCode=12163;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM ,
0,
errCode,
0,
(LPTSTR) &lpMsgBuf,
0, NULL );
Run Code Online (Sandbox Code Playgroud)
但是,当它返回lpMsgBuf
包含NULL时......我期待像ERROR_INTERNET_DISCONNECTED这样的东西.
什么看错了?谢谢.
我对 yahoo/react-intl 有一个问题,我想以字符串类型制作消息,但是当我使用 FormattedMessage 时,它给了我用 span 包裹的消息,这并不酷。我试过 formatMessage ,但也不起作用。我非常感谢任何帮助或建议这是我的代码:
import React from 'react';
import {FormattedMessage} from 'react-intl';
export default {
items: [
{
name: <FormattedMessage id='app.dashboard'/>,
url: '/dashboard',
icon: 'icon-speedometer',
badge: {
variant: 'info',
text: 'New',
},
},
{
title: true,
name: <FormattedMessage id='app.dashboard'/>,
// optional wrapper object
wrapper: {
// required valid HTML5 element tag
element: 'strong',
// optional valid JS object with JS API naming ex: { className: "my-class", style: { fontFamily: "Verdana" }, id: "my-id"}
attributes: {}, …
Run Code Online (Sandbox Code Playgroud) 在Windows的FormatMessage()函数中,参数:
_Out_ LPTSTR lpBuffer
Run Code Online (Sandbox Code Playgroud)
我正在认真思考。按照 Hart 的 Windows 系统编程书籍,我声明一个LPTSTR
指针用作lpBuffer
(例如LPTSTR errortext;
),然后调用该FormatMessage()
函数。
传入该参数的正确方法是:(LPTSTR)&errorText
这很好用。但我不明白为什么我需要写(LPTSTR)
。我知道这是类型转换,我读到了它,但它对我来说没有意义,因为我没有改变变量类型或任何东西,我将它声明为 anLPTSTR
并且我将它的内存地址传递给函数,函数需要 anLPTSTR
并且我将其传递给了 an LPTSTR
,那么为什么我需要将其(LPTSTR)
作为参数的一部分呢lpBuffer
?