uLib  User mode C/C++ extended API library for Win32 programmers.
Resource Strings

Module Description

These functions work with resource strings.

Classes

struct  RC_STRING
 

Functions

CSTR LoadStr (HMODULE hModule, UINT Id, TSTR Buf=NULL, UINT Count=0)
 
WCSTR GetResourceStr (HMODULE hModule, UINT Id, PWORD pCount)
 
WCSTR FindResourceStrEx (HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount)
 
CSTR DupResourceStrEx (HMODULE hModule, UINT Id, LANGID Lang, PWORD pCount)
 
CSTR FreeResourceStrEx (CSTR pzRcDupStr)
 

Function Documentation

◆ LoadStr()

CSTR LoadStr ( HMODULE  hModule,
UINT  Id,
TSTR  Buf = NULL,
UINT  Count = 0 
)

LoadStr() is an auto-buffered LoadString.

Parameters
hModuleModule handle of string resource.
IdResource string ID.
BufPtr to TCHAR buffer, or NULL to use internal MAX_PATH static buffer.
CountLength of buffer, if provided.

Definition at line 310 of file StrFunc.cpp.

◆ GetResourceStr()

WCSTR GetResourceStr ( HMODULE  hModule,
UINT  Id,
PWORD  pCount 
)

GetResourceStr() returns a read-only pointer directly to a string resource.

Parameters
hModuleModule handle of resource.
IdResource ID.
pCountPtr to a WORD that recieves the string length, in wchars.

Note: Resource strings are counted, not necessarily NUL terminated.

Example (using the native type UNICODE_STRING):

UNICODE_STRING rcStr;
rcStr.Buffer = GetResourceStr( hInstance, 123, &rcStr.Length );
// Max = byte size. Possibly superfluous in your context.
rcStr.MaximumLength = rcStr.Length * sizeof(WCHAR);
// Note: If you'll use this with Rtl, Length must also be byte size,
// otherwise it's more convenient to keep it as a wchar count.
//rcStr.Length = rcStr.MaximumLength;

Definition at line 324 of file StrFunc.cpp.

◆ FindResourceStrEx()

WCSTR FindResourceStrEx ( HMODULE  hModule,
UINT  Id,
LANGID  Lang,
PWORD  pCount 
)

FindResourceStrEx() returns a read-only pointer directly to a language specific string resource.

Parameters
LangLaguage identifier.

See GetResourceStr() for more details.

Definition at line 339 of file StrFunc.cpp.

◆ DupResourceStrEx()

CSTR DupResourceStrEx ( HMODULE  hModule,
UINT  Id,
LANGID  Lang,
PWORD  pCount 
)

DupResourceStrEx allocates, loads, translates, and null terminates a resource string.
Free with FreeResourceStrEx() when done.
See FindResourceStrEx() for more details.

Definition at line 360 of file StrFunc.cpp.

◆ FreeResourceStrEx()

CSTR FreeResourceStrEx ( CSTR  pzRcDupStr)

Definition at line 383 of file StrFunc.cpp.