ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

misc.c
Go to the documentation of this file.
00001 #include "desk.h"
00002 
00003 static INT
00004 LengthOfStrResource(IN HINSTANCE hInst,
00005                     IN UINT uID)
00006 {
00007     HRSRC hrSrc;
00008     HGLOBAL hRes;
00009     LPWSTR lpName, lpStr;
00010 
00011     if (hInst == NULL)
00012     {
00013         return -1;
00014     }
00015 
00016     /* There are always blocks of 16 strings */
00017     lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
00018 
00019     /* Find the string table block */
00020     if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
00021         (hRes = LoadResource(hInst, hrSrc)) &&
00022         (lpStr = LockResource(hRes)))
00023     {
00024         UINT x;
00025 
00026         /* Find the string we're looking for */
00027         uID &= 0xF; /* Position in the block, same as % 16 */
00028         for (x = 0; x < uID; x++)
00029         {
00030             lpStr += (*lpStr) + 1;
00031         }
00032 
00033         /* Found the string */
00034         return (int)(*lpStr);
00035     }
00036     return -1;
00037 }
00038 
00039 INT
00040 AllocAndLoadString(OUT LPTSTR *lpTarget,
00041                    IN HINSTANCE hInst,
00042                    IN UINT uID)
00043 {
00044     INT ln;
00045 
00046     ln = LengthOfStrResource(hInst,
00047                              uID);
00048     if (ln++ > 0)
00049     {
00050         (*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED,
00051                                          ln * sizeof(TCHAR));
00052         if ((*lpTarget) != NULL)
00053         {
00054             INT Ret;
00055             if (!(Ret = LoadString(hInst, uID, *lpTarget, ln)))
00056             {
00057                 LocalFree((HLOCAL)(*lpTarget));
00058             }
00059             return Ret;
00060         }
00061     }
00062     return 0;
00063 }

Generated on Sat May 26 2012 04:15:47 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.