Questions tagged [formatmessage]

19 questions
94
votes
8 answers

How should I use FormatMessage() properly in C++?

Without: MFC ATL How can I use FormatMessage() to get the error text for a HRESULT? HRESULT hresult = application.CreateInstance("Excel.Application"); if (FAILED(hresult)) { // what should i put here to obtain a human-readable //…
Aaron
  • 2,823
  • 9
  • 44
  • 57
19
votes
1 answer

Why is FormatMessage() failing to find a message for WinINet errors?

I'm running this to test FormatMessage: LPVOID lpMsgBuf; errCode=12163; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM , 0, errCode, 0, (LPTSTR) &lpMsgBuf, 0, NULL ); However, when it…
T.T.T.
  • 33,367
  • 47
  • 130
  • 168
5
votes
3 answers

how to make a message without wrapping in span in react-intl

i have a problem with yahoo/react-intl thats i want to make messages in string type but when im using FormattedMessage it gives me message wrapped in span and thats not cool. i tried formatMessage and that not working too. i be very thankful for…
Hamid Akhavan
  • 61
  • 1
  • 2
4
votes
2 answers

Safe/flexible facade for Windows FormatMessage

I need to use FormatMessage() for a project, but I don't like its scary interface. Does anyone know of a facade that tidies it up while still allowing for the replacement parameters? I just read the second part of the FastFormat introduction, and am…
dcw
  • 3,481
  • 2
  • 22
  • 30
4
votes
2 answers

How to read the Windows Event Log without an EventMessageFile?

I have code that reads the Windows Event Log. It uses OpenEventLog, ReadEventLog and gets the event source and event ID. Then it looks up the source under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application key, loads…
DougN
  • 4,407
  • 11
  • 56
  • 81
3
votes
0 answers

Windows/C++: FormatMessage() with GetExceptionCode() ignores FORMAT_MESSAGE_IGNORE_INSERTS

I would like to using code similar to the following to report divide-by-zero, access violations, etc. My problem is that, despite setting the flag FORMAT_MESSAGE_IGNORE_INSERTS, messages are truncated at the position of the insert. __try { int…
paperjam
  • 8,321
  • 12
  • 53
  • 79
2
votes
2 answers

FormatMessage to a different language

Is it possible to translate system error codes to a specific language? I can only pass MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) to FormatMessage. Otherwise, function call fails with 15100 (The resource loader failed to find MUI file). Where are…
John Smith
  • 89
  • 11
2
votes
1 answer

Why do I need to cast the lpBuffer (LPTSTR) parameter in FormatMessage?

In Windows' FormatMessage() function, the parameter: _Out_ LPTSTR lpBuffer Is doing my head in. Following along from Hart's Windows System Programming book, I'm declaring an LPTSTR pointer to be used as the lpBuffer (e.g. LPTSTR errortext;),…
404
  • 8,022
  • 2
  • 27
  • 47
1
vote
3 answers

Left fill variable with zeros in FORMATMESSAGE

Using SQL Server's FORMATMESSAGE command, I am printing status messages: PRINT FORMATMESSAGE('Run time #%2d: From %s to %s', @i, CONVERT(VARCHAR(10), @from_date, 101), CONVERT(VARCHAR(10), @to_date, 101)) This gives me output like: Run time # 8:…
Count Boxer
  • 673
  • 3
  • 11
  • 25
1
vote
1 answer

FORMATMESSAGE with a TAB character

I have recently learned about the FORMATMESSAGE (link below) and I have started using it. https://msdn.microsoft.com/en-us/library/ms186788.aspx I have aware that I have print/select a TAB character (link below) but I would like to learn how to you…
Unbound
  • 177
  • 2
  • 14
1
vote
1 answer

Why does FormatMessage only create partial messages for ERROR_SYSTEM_PROCESS_TERMINATED and ERROR_UNHANDLED_EXCEPTION system errors?

I have been using the FormatMessage function within the Windows API to generate message strings from system error codes. I noticed that for some error codes the full message doesn't appear to be created. Take this sample program as an example: int…
Class Skeleton
  • 2,913
  • 6
  • 31
  • 51
1
vote
2 answers

Event IDs don't match what is displayed in Event Viewer

In the System event log is an event with the following details: Source: Kernel-General Event ID: 1 Details: The system time has changed to ‎2010‎-‎07‎-‎17T02:58:20.285000000Z from ‎2010‎-‎07‎-‎17T02:58:20.285868600Z. The EVENTLOGRECORD also has a 1…
DougN
  • 4,407
  • 11
  • 56
  • 81
0
votes
2 answers

Rectify this Error:GetLastError 0x13d

In this sample,the dwerror is 10045L.but this code returns 0x13d value as error. How to get the format message?Please have a look into it. TCHAR lpMsgBuf[512]; if(!FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, …
karthik
  • 17,453
  • 70
  • 78
  • 122
0
votes
1 answer

FormatMessage gets Error 317 while trying to read EventLog

I had nearly similar problem with this. FormatMessage Fails with error code 317 The difference is it is said as an answer that this is caused by "FORMAT_MESSAGE_FROM_SYSTEM" but when I remove it it happens again. I am trying to read from EventLog…
0
votes
0 answers

Getting HRESULT error text for an OLE object exception

I have an HRESULT scode (0x800A0034) in an EXCEPINFO structure from an IDispatch::Invoke() call on an OLE Object, and I'm trying to get the text associated with this error ("Bad file name or number"). Using the usual FormatMessage() function with…
Carl
  • 1
  • 1
1
2