标签: formatmessage

我应该如何在C++中正确使用FormatMessage()?

没有:

  • MFC
  • ATL

如何使用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)

c++ windows error-handling formatmessage

84
推荐指数
5
解决办法
5万
查看次数

为什么FormatMessage()无法找到WinINet错误的消息?

我正在运行它来测试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这样的东西.

什么看错了?谢谢.

c windows winapi wininet formatmessage

15
推荐指数
1
解决办法
3025
查看次数

如何在react-intl中不包裹跨度的情况下制作消息

我对 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)

formatmessage reactjs react-intl

3
推荐指数
2
解决办法
3398
查看次数

为什么需要在 FormatMessage 中转换 lpBuffer (LPTSTR) 参数?

在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

c c++ winapi formatmessage

2
推荐指数
1
解决办法
946
查看次数