get_error_message() is for native calls in native/win32/ffi.c

error_message() is called via alien-invoke from factor code
bugfix: the last "fix" caused the factor runtime to get a char* instead of F_STRING
cvs
Doug Coleman 2005-10-06 22:10:27 +00:00
parent 211c60c210
commit 7242f38fd7
2 changed files with 10 additions and 4 deletions

View File

@ -68,17 +68,22 @@ char *buffer_to_c_string(char *buffer)
return (char*)c_str; return (char*)c_str;
} }
char *last_error() F_STRING *get_error_message()
{
DWORD id = GetLastError();
return from_c_string(error_message(id));
}
char *error_message(DWORD id)
{ {
char *buffer; char *buffer;
int index; int index;
DWORD dw = GetLastError();
FormatMessage( FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, FORMAT_MESSAGE_FROM_SYSTEM,
NULL, NULL,
dw, id,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &buffer, (LPTSTR) &buffer,
0, NULL); 0, NULL);

View File

@ -6,6 +6,7 @@ void primitive_millis(void);
void primitive_random_int(void); void primitive_random_int(void);
#ifdef WIN32 #ifdef WIN32
char *buffer_to_c_string(char *buffer); char *buffer_to_c_string(char *buffer);
DLLEXPORT char *last_error(); F_STRING *get_error_message();
DLLEXPORT char *error_message(DWORD id);
#endif #endif