mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
Added LoadString() stringtable resource support
svn path=/trunk/; revision=1567
This commit is contained in:
parent
74e0c4a781
commit
dee175afca
2 changed files with 59 additions and 11 deletions
|
@ -207,15 +207,6 @@ LoadImageA(
|
|||
int j,
|
||||
UINT k) { return 0; }
|
||||
|
||||
int
|
||||
STDCALL
|
||||
LoadStringA(
|
||||
HINSTANCE hInstance,
|
||||
UINT uID,
|
||||
LPSTR lpBuffer,
|
||||
int nBufferMax) { return 0; }
|
||||
|
||||
|
||||
int
|
||||
STDCALL
|
||||
DlgDirListA(
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <kernel32/error.h>
|
||||
|
||||
/***********************************************************************
|
||||
* SYSRES_GetResourcePtr
|
||||
|
@ -13,3 +15,58 @@ LPCVOID SYSRES_GetResPtr( int id )
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
STDCALL
|
||||
LoadStringA( HINSTANCE hInstance,
|
||||
UINT uID,
|
||||
LPSTR lpBuffer,
|
||||
int nBufferMax)
|
||||
{
|
||||
HRSRC rsc;
|
||||
PBYTE ptr;
|
||||
int len;
|
||||
int count, dest = uID % 16;
|
||||
PWSTR pwstr;
|
||||
UNICODE_STRING UString;
|
||||
ANSI_STRING AString;
|
||||
NTSTATUS Status;
|
||||
|
||||
rsc = FindResource( (HMODULE)hInstance,
|
||||
MAKEINTRESOURCE( (uID / 16) + 1 ),
|
||||
RT_STRING );
|
||||
if( rsc == NULL )
|
||||
return 0;
|
||||
// get pointer to string table
|
||||
ptr = (PBYTE)LoadResource( (HMODULE)hInstance, rsc );
|
||||
if( ptr == NULL )
|
||||
return 0;
|
||||
for( count = 0; count <= dest; count++ )
|
||||
{
|
||||
// walk each of the 16 string slots in the string table
|
||||
len = (*(USHORT *)ptr) * 2; // length is in unicode chars, convert to bytes
|
||||
ptr += 2; // first 2 bytes are length, string follows
|
||||
pwstr = (PWSTR)ptr;
|
||||
ptr += len;
|
||||
}
|
||||
if( !len )
|
||||
return 0; // zero means no string is there
|
||||
// convert unitocde to ansi, and copy string to caller buffer
|
||||
UString.Length = UString.MaximumLength = len;
|
||||
UString.Buffer = pwstr;
|
||||
memset( &AString, 0, sizeof AString );
|
||||
Status = RtlUnicodeStringToAnsiString( &AString, &UString, TRUE );
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
{
|
||||
SetLastErrorByStatus( Status );
|
||||
return 0;
|
||||
}
|
||||
if( nBufferMax > AString.Length )
|
||||
nBufferMax = AString.Length;
|
||||
nBufferMax--; // save room for the null
|
||||
memcpy( lpBuffer, AString.Buffer, nBufferMax );
|
||||
lpBuffer[nBufferMax] = 0;
|
||||
RtlFreeAnsiString( &AString );
|
||||
return nBufferMax;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue