Foolish Windows users... Those 14-hundred some nodes are quite a waste of space.

The following interactive program I wrote will lookup a Win32 error. You can specify a hexadecimal error code by prepending 0x, or a decimal by simply entering the number. It will compile on Borland C++ 5.0 as a Win32 console application (wharfinger tells me it also works with VC++ 6).

novalis: then let's post a binary. :-) http://members.tripod.com/andy_779/err.exe

#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

#define KEY_BS          8
#define KEY_ENTER       '\r'

int main() {

        char *buf = NULL, flag = 0, hex = 0;
        size_t len = 0;
        int c;

        cprintf( "Enter error code: " );
        while( (c=getch()) != KEY_ENTER ) {
                if( c == 0 )
                        continue;
                putch( c );
                if( c == KEY_BS ) {
                        if( len != 0 )
				len--;
                        continue;
                }
                len++;
                buf = (char *) realloc( buf, len );
                assert( buf != NULL );
                buf[len-1] = c;
        }
        buf = (char *) realloc( buf, len+1 );
        assert( buf != NULL );
        buf[len] = 0;
        cprintf( "\r\n" );
        if( strncmp( buf, "0x", 2 ) == 0 ) {
                hex = 1;
                buf += 2;
	}
        for( c=0; c<strlen(buf); c++ )
                if( (buf[c] < '0' || buf[c] > '9') && !hex ) {
                        cprintf( "\"Number\" contains "
				 "invalid characters.\r\n" );
                        flag = 1;
                        c = len;
                }

        if( !flag ) {
                DWORD error;
                char *nbuf;
                if( hex )
                        sscanf( buf, "%x", &error );
                else
                        sscanf( buf, "%d", &error );
                FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM |
				FORMAT_MESSAGE_ALLOCATE_BUFFER,
				&error, error, 0, &nbuf, 0, NULL );
                cprintf( "Error code %d: %s", error, nbuf );
                LocalFree( nbuf );
        }

        if( hex )
                buf -= 2;
        free( buf );

        cputs( "Press any key to continue." );
        while( !kbhit() );
        return 0;

}

Log in or registerto write something here or to contact authors.