4 #include <kernel32/error.h>
8 LoadStringA( HINSTANCE hInstance,
16 int count, dest = uID % 16;
18 UNICODE_STRING UString;
22 rsc = FindResource( (HMODULE)hInstance,
23 MAKEINTRESOURCE( (uID / 16) + 1 ),
27 // get pointer to string table
28 ptr = (PBYTE)LoadResource( (HMODULE)hInstance, rsc );
31 for( count = 0; count <= dest; count++ )
33 // walk each of the 16 string slots in the string table
34 len = (*(USHORT *)ptr) * 2; // length is in unicode chars, convert to bytes
35 ptr += 2; // first 2 bytes are length, string follows
40 return 0; // zero means no string is there
41 // convert unitocde to ansi, and copy string to caller buffer
42 UString.Length = UString.MaximumLength = len;
43 UString.Buffer = pwstr;
44 memset( &AString, 0, sizeof AString );
45 Status = RtlUnicodeStringToAnsiString( &AString, &UString, TRUE );
46 if( !NT_SUCCESS( Status ) )
48 SetLastErrorByStatus( Status );
51 nBufferMax--; // save room for the null
52 if( nBufferMax > AString.Length )
53 nBufferMax = AString.Length;
54 memcpy( lpBuffer, AString.Buffer, nBufferMax );
55 lpBuffer[nBufferMax] = 0;
56 RtlFreeAnsiString( &AString );