ReactOS  0.4.13-dev-482-ge57f103
misc.c File Reference
#include "desk.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

static INT LengthOfStrResource (IN HINSTANCE hInst, IN UINT uID)
 
INT AllocAndLoadString (OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
 

Function Documentation

◆ AllocAndLoadString()

INT AllocAndLoadString ( OUT LPTSTR lpTarget,
IN HINSTANCE  hInst,
IN UINT  uID 
)

Definition at line 40 of file misc.c.

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 }
int32_t INT
Definition: typedefs.h:56
CHAR * LPTSTR
Definition: xmlstorage.h:192
smooth NULL
Definition: ftsmooth.c:416
#define LMEM_FIXED
Definition: winbase.h:349
char TCHAR
Definition: xmlstorage.h:189
HINSTANCE hInst
Definition: dxdiag.c:13
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
INT LengthOfStrResource(IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:23
#define LoadString
Definition: winuser.h:5685

◆ LengthOfStrResource()

static INT LengthOfStrResource ( IN HINSTANCE  hInst,
IN UINT  uID 
)
static

Definition at line 4 of file misc.c.

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 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
_In_ LPCSTR lpName
Definition: winbase.h:2729
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
#define RT_STRING
Definition: pedump.c:368
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int UINT
Definition: ndis.h:50
static LPWSTR
Definition: misc.c:35
WCHAR * LPWSTR
Definition: xmlstorage.h:184