2 * ReactOS Device Manager Applet
3 * Copyright (C) 2004 - 2005 ReactOS Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /* $Id: devmgr.c 12852 2005-01-06 13:58:04Z mf $
21 * PROJECT: ReactOS devmgr.dll
22 * FILE: lib/devmgr/misc.c
23 * PURPOSE: ReactOS Device Manager
24 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
30 HINSTANCE hDllInstance
= NULL
;
33 LengthOfStrResource(IN HINSTANCE hInst
,
45 /* There are always blocks of 16 strings */
46 lpName
= (LPWSTR
)MAKEINTRESOURCE((uID
>> 4) + 1);
48 /* Find the string table block */
49 if ((hrSrc
= FindResourceW(hInst
, lpName
, (LPWSTR
)RT_STRING
)) &&
50 (hRes
= LoadResource(hInst
, hrSrc
)) &&
51 (lpStr
= LockResource(hRes
)))
55 /* Find the string we're looking for */
56 uID
&= 0xF; /* position in the block, same as % 16 */
57 for (x
= 0; x
< uID
; x
++)
59 lpStr
+= (*lpStr
) + 1;
62 /* Found the string */
69 AllocAndLoadString(OUT LPWSTR
*lpTarget
,
75 ln
= LengthOfStrResource(hInst
,
79 (*lpTarget
) = (LPWSTR
)LocalAlloc(LMEM_FIXED
,
81 if ((*lpTarget
) != NULL
)
84 if (!(Ret
= LoadStringW(hInst
, uID
, *lpTarget
, ln
)))
86 LocalFree((HLOCAL
)(*lpTarget
));
95 LoadAndFormatString(IN HINSTANCE hInstance
,
104 if (AllocAndLoadString(&lpFormat
,
108 va_start(lArgs
, lpTarget
);
109 /* let's use FormatMessage to format it because it has the ability to allocate
110 memory automatically */
111 Ret
= FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_STRING
,
120 LocalFree((HLOCAL
)lpFormat
);
127 ListViewGetSelectedItemData(IN HWND hwnd
)
131 Index
= ListView_GetNextItem(hwnd
,
138 li
.mask
= LVIF_PARAM
;
142 if (ListView_GetItem(hwnd
,
154 DllMain(IN HINSTANCE hinstDLL
,
156 IN LPVOID lpvReserved
)
160 case DLL_PROCESS_ATTACH
:
161 DisableThreadLibraryCalls(hinstDLL
);
162 hDllInstance
= hinstDLL
;