ReactOS 0.4.16-dev-334-g4d9f67c
misc.c
Go to the documentation of this file.
1#include "desk.h"
2
3static INT
5 IN UINT uID)
6{
7 HRSRC hrSrc;
8 HGLOBAL hRes;
9 LPWSTR lpName, lpStr;
10
11 if (hInst == NULL)
12 {
13 return -1;
14 }
15
16 /* There are always blocks of 16 strings */
17 lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
18
19 /* Find the string table block */
20 if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
21 (hRes = LoadResource(hInst, hrSrc)) &&
22 (lpStr = LockResource(hRes)))
23 {
24 UINT x;
25
26 /* Find the string we're looking for */
27 uID &= 0xF; /* Position in the block, same as % 16 */
28 for (x = 0; x < uID; x++)
29 {
30 lpStr += (*lpStr) + 1;
31 }
32
33 /* Found the string */
34 return (int)(*lpStr);
35 }
36 return -1;
37}
38
39INT
42 IN UINT uID)
43{
44 INT ln;
45
47 uID);
48 if (ln++ > 0)
49 {
50 (*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED,
51 ln * sizeof(TCHAR));
52 if ((*lpTarget) != NULL)
53 {
54 INT Ret;
55 if (!(Ret = LoadString(hInst, uID, *lpTarget, ln)))
56 {
57 LocalFree((HLOCAL)(*lpTarget));
58 }
59 return Ret;
60 }
61 }
62 return 0;
63}
INT LengthOfStrResource(IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:23
INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:59
#define NULL
Definition: types.h:112
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
HINSTANCE hInst
Definition: dxdiag.c:13
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
unsigned int UINT
Definition: ndis.h:50
#define RT_STRING
Definition: pedump.c:368
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
_In_ LPCSTR lpName
Definition: winbase.h:2814
#define LMEM_FIXED
Definition: winbase.h:394
#define LoadString
Definition: winuser.h:5831
#define MAKEINTRESOURCE
Definition: winuser.h:591
char TCHAR
Definition: xmlstorage.h:189
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CHAR * LPTSTR
Definition: xmlstorage.h:192