OpenCBM
formaterrormessage.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 2012 Spiro Trikaliotis
8  *
9 */
10 
19 #include "libmisc.h"
20 
21 #include <windows.h>
22 
34 char *
35 cbmlibmisc_format_error_message(unsigned int ErrorNumber)
36 {
37  static char ErrorMessageBuffer[2048];
38  int n;
39 
40  // Format the message
41 
42  n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
43  NULL,
44  ErrorNumber,
45  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
46  (LPTSTR) &ErrorMessageBuffer,
47  sizeof(ErrorMessageBuffer)-1,
48  NULL);
49 
50  // make sure there is a trailing zero
51 
52  ErrorMessageBuffer[n] = 0;
53 
54  return ErrorMessageBuffer;
55 }
Some functions for string handling.
char * cbmlibmisc_format_error_message(unsigned int ErrorNumber)
Format a returned error code into a string.