1 | /* $Id: misc.cpp,v 1.3 1999-10-08 10:19:22 phaller Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 SHELL32 for OS/2
|
---|
5 | * 1998/06/15 Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
6 | * Copyright 1997 Marcus Meissner
|
---|
7 | * Copyright 1988 Patrick Haller (adapted for win32os2)
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 |
|
---|
13 | /*****************************************************************************
|
---|
14 | * Includes *
|
---|
15 | *****************************************************************************/
|
---|
16 |
|
---|
17 | #include <odin.h>
|
---|
18 | #include <odinwrap.h>
|
---|
19 | #include <os2sel.h>
|
---|
20 |
|
---|
21 | #include <wchar.h>
|
---|
22 | #include <wcstr.h>
|
---|
23 |
|
---|
24 | #define ICOM_CINTERFACE 1
|
---|
25 |
|
---|
26 | //#include <os2win.h>
|
---|
27 | #include <shellapi.h>
|
---|
28 | #include <winnls.h>
|
---|
29 | #include "shell32_main.h"
|
---|
30 | #include <misc.h>
|
---|
31 | //#include <string.h>
|
---|
32 | //#include "winbase.h"
|
---|
33 | #include <heapstring.h>
|
---|
34 |
|
---|
35 |
|
---|
36 | /*****************************************************************************
|
---|
37 | * Types & Defines *
|
---|
38 | *****************************************************************************/
|
---|
39 |
|
---|
40 | ODINDEBUGCHANNEL(SHELL32-MISC)
|
---|
41 |
|
---|
42 |
|
---|
43 | /*****************************************************************************
|
---|
44 | * Name : HICON IExtractAssociatedIconExA
|
---|
45 | * Purpose : Return icon for given file (either from file itself or from associated
|
---|
46 | * executable) and patch parameters if needed.
|
---|
47 | * Parameters: ???
|
---|
48 | * Variables :
|
---|
49 | * Result :
|
---|
50 | * Remark : SHELL.150
|
---|
51 | * Status : UNTESTED UNKNOWN STUB
|
---|
52 | *
|
---|
53 | * Author : Christoph Bratschi [Fri, 1999/08/6 20:00]
|
---|
54 | *****************************************************************************/
|
---|
55 |
|
---|
56 | ODINFUNCTION3(HICON, ExtractAssociatedIconExA,
|
---|
57 | HINSTANCE, hInst,
|
---|
58 | LPSTR, lpIconPath,
|
---|
59 | LPWORD, lpiIcon)
|
---|
60 | {
|
---|
61 | return ExtractAssociatedIconA(hInst,lpIconPath,lpiIcon);
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | /*****************************************************************************
|
---|
66 | * Name : HICON ExtractAssociatedIconW
|
---|
67 | * Purpose : Return icon for given file (either from file itself or from associated
|
---|
68 | * executable) and patch parameters if needed.
|
---|
69 | * Parameters:
|
---|
70 | * Variables :
|
---|
71 | * Result :
|
---|
72 | * Remark : SHELL.36
|
---|
73 | * Status : UNTESTED STUB
|
---|
74 | *
|
---|
75 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
76 | *****************************************************************************/
|
---|
77 |
|
---|
78 | ODINFUNCTION3(HICON, ExtractAssociatedIconW,
|
---|
79 | HINSTANCE, hInst,
|
---|
80 | LPWSTR, lpIconPath,
|
---|
81 | LPWORD, lpiIcon)
|
---|
82 | {
|
---|
83 | LPSTR lpIconPathAscii = UnicodeToAsciiString(lpIconPath);
|
---|
84 | HICON hIcon;
|
---|
85 |
|
---|
86 | hIcon = ExtractAssociatedIconA(hInst,
|
---|
87 | lpIconPathAscii,
|
---|
88 | lpiIcon);
|
---|
89 |
|
---|
90 | FreeAsciiString(lpIconPathAscii);
|
---|
91 |
|
---|
92 | return (hIcon);
|
---|
93 | }
|
---|
94 |
|
---|
95 | /*****************************************************************************
|
---|
96 | * Name : HICON ExtractAssociatedIconExW
|
---|
97 | * Purpose : Return icon for given file (either from file itself or from associated
|
---|
98 | * executable) and patch parameters if needed.
|
---|
99 | * Parameters: ???
|
---|
100 | * Variables :
|
---|
101 | * Result :
|
---|
102 | * Remark : SHELL.186
|
---|
103 | * Status : UNTESTED UNKNOWN STUB
|
---|
104 | *
|
---|
105 | * Author : Christoph Bratschi [Fri, 1999/08/6 20:00]
|
---|
106 | *****************************************************************************/
|
---|
107 |
|
---|
108 | ODINFUNCTION3(HICON, ExtractAssociatedIconExW,
|
---|
109 | HINSTANCE, hInst,
|
---|
110 | LPWSTR, lpIconPath,
|
---|
111 | LPWORD, lpiIcon)
|
---|
112 | {
|
---|
113 | return ExtractAssociatedIconW(hInst,lpIconPath,lpiIcon);
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | /*****************************************************************************
|
---|
118 | * Name : OleStrToStrN
|
---|
119 | * Purpose :
|
---|
120 | * Parameters:
|
---|
121 | * Variables :
|
---|
122 | * Result :
|
---|
123 | * Remark : SHELL32.78
|
---|
124 | * Status : UNTESTED UNKNOWN STUB
|
---|
125 | *
|
---|
126 | * Author : Patrick Haller [Tue, 1998/06/15 03:00]
|
---|
127 | *****************************************************************************/
|
---|
128 |
|
---|
129 | ODINFUNCTION4(BOOL, OleStrToStrN,
|
---|
130 | LPSTR, lpMulti,
|
---|
131 | INT, nMulti,
|
---|
132 | LPCWSTR, lpWide,
|
---|
133 | INT, nWide)
|
---|
134 | {
|
---|
135 | return WideCharToMultiByte (0,
|
---|
136 | 0,
|
---|
137 | lpWide,
|
---|
138 | nWide,
|
---|
139 | lpMulti,
|
---|
140 | nMulti,
|
---|
141 | NULL,
|
---|
142 | NULL);
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | /*****************************************************************************
|
---|
147 | * Name : StrToOleStrN
|
---|
148 | * Purpose :
|
---|
149 | * Parameters:
|
---|
150 | * Variables :
|
---|
151 | * Result :
|
---|
152 | * Remark : SHELL32.79
|
---|
153 | * Status : UNTESTED UNKNOWN STUB
|
---|
154 | *
|
---|
155 | * Author : Patrick Haller [Tue, 1998/06/15 03:00]
|
---|
156 | *****************************************************************************/
|
---|
157 |
|
---|
158 | ODINFUNCTION4(BOOL, StrToOleStrN,
|
---|
159 | LPWSTR, lpWide,
|
---|
160 | INT, nWide,
|
---|
161 | LPCSTR, lpMulti,
|
---|
162 | INT, nMulti)
|
---|
163 | {
|
---|
164 | return MultiByteToWideChar (0,
|
---|
165 | 0,
|
---|
166 | lpMulti,
|
---|
167 | nMulti,
|
---|
168 | lpWide,
|
---|
169 | nWide);
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 | /*****************************************************************************
|
---|
174 | * Name : StrRetToStrN
|
---|
175 | * Purpose : converts a STRRET to a normal string
|
---|
176 | * Parameters: the pidl is for STRRET OFFSET
|
---|
177 | * Variables :
|
---|
178 | * Result :
|
---|
179 | * Remark : SHELL32.96
|
---|
180 | * Status : UNTESTED UNKNOWN STUB
|
---|
181 | *
|
---|
182 | * Author : Patrick Haller [Tue, 1998/06/15 03:00]
|
---|
183 | *****************************************************************************/
|
---|
184 |
|
---|
185 | ODINFUNCTION4(HRESULT, StrRetToStrN,
|
---|
186 | LPVOID, dest,
|
---|
187 | DWORD, len,
|
---|
188 | LPSTRRET, src,
|
---|
189 | LPITEMIDLIST, pidl)
|
---|
190 | {
|
---|
191 | switch (src->uType)
|
---|
192 | {
|
---|
193 | case STRRET_WSTR:
|
---|
194 | WideCharToMultiByte(CP_ACP,
|
---|
195 | 0,
|
---|
196 | src->u.pOleStr,
|
---|
197 | -1,
|
---|
198 | (LPSTR)dest,
|
---|
199 | len,
|
---|
200 | NULL,
|
---|
201 | NULL);
|
---|
202 | SHFree(src->u.pOleStr);
|
---|
203 | break;
|
---|
204 |
|
---|
205 | case STRRET_CSTRA:
|
---|
206 | //if (VERSION_OsIsUnicode())
|
---|
207 | // lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
|
---|
208 | //else
|
---|
209 | strncpy((LPSTR)dest,
|
---|
210 | src->u.cStr,
|
---|
211 | len);
|
---|
212 | break;
|
---|
213 |
|
---|
214 | case STRRET_OFFSETA:
|
---|
215 | if (pidl)
|
---|
216 | {
|
---|
217 | //if(VERSION_OsIsUnicode())
|
---|
218 | // lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
---|
219 | //else
|
---|
220 | strncpy((LPSTR)dest,
|
---|
221 | ((LPCSTR)&pidl->mkid)+src->u.uOffset,
|
---|
222 | len);
|
---|
223 | break;
|
---|
224 | }
|
---|
225 |
|
---|
226 | default:
|
---|
227 | dprintf(("SHELL32: StrRetToStrN: unknown type!\n"));
|
---|
228 |
|
---|
229 | if (len)
|
---|
230 | *(LPSTR)dest = '\0';
|
---|
231 |
|
---|
232 | return(FALSE);
|
---|
233 | }
|
---|
234 | return(TRUE);
|
---|
235 | }
|
---|
236 |
|
---|
237 |
|
---|
238 | /*****************************************************************************
|
---|
239 | * Name : SHELL32_654
|
---|
240 | * Purpose :
|
---|
241 | * Parameters:
|
---|
242 | * Variables :
|
---|
243 | * Result :
|
---|
244 | * Remark : SHELL32.654
|
---|
245 | * Status : UNTESTED UNKNOWN STUB
|
---|
246 | *
|
---|
247 | * Author : Patrick Haller [Tue, 1998/06/15 03:00]
|
---|
248 | *****************************************************************************/
|
---|
249 |
|
---|
250 | ODINFUNCTION2(HRESULT, SHELL32_654,
|
---|
251 | DWORD, x,
|
---|
252 | DWORD, y)
|
---|
253 | {
|
---|
254 | dprintf(("SHELL32: SHELL32_654(%08xh,%08xh) not implemented.\n",
|
---|
255 | x,
|
---|
256 | y));
|
---|
257 | return 0;
|
---|
258 | }
|
---|
259 |
|
---|
260 |
|
---|
261 | /*****************************************************************************
|
---|
262 | * Name : StrToOleStr
|
---|
263 | * Purpose :
|
---|
264 | * Parameters:
|
---|
265 | * Variables :
|
---|
266 | * Result :
|
---|
267 | * Remark : SHELL32.163
|
---|
268 | * Status : UNTESTED UNKNOWN STUB
|
---|
269 | *
|
---|
270 | * Author : Patrick Haller [Tue, 1998/06/15 03:00]
|
---|
271 | *****************************************************************************/
|
---|
272 |
|
---|
273 | ODINFUNCTION2(int, StrToOleStr,
|
---|
274 | LPWSTR, lpWideCharStr,
|
---|
275 | LPCSTR, lpMultiByteString)
|
---|
276 | {
|
---|
277 | return MultiByteToWideChar(0,
|
---|
278 | 0,
|
---|
279 | lpMultiByteString,
|
---|
280 | -1,
|
---|
281 | lpWideCharStr,
|
---|
282 | MAX_PATH);
|
---|
283 | }
|
---|
284 |
|
---|
285 |
|
---|
286 | /*****************************************************************************
|
---|
287 | * Name : StrCpyNW
|
---|
288 | * Purpose :
|
---|
289 | * Parameters:
|
---|
290 | * Variables :
|
---|
291 | * Result :
|
---|
292 | * Remark : SHELL32.310 - used by winfile.exe
|
---|
293 | * Status : UNTESTED UNKNOWN STUB
|
---|
294 | *
|
---|
295 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
296 | *****************************************************************************/
|
---|
297 |
|
---|
298 | ODINFUNCTION3(LPWSTR, StrCpyNW,
|
---|
299 | LPWSTR, lpString1,
|
---|
300 | LPWSTR, lpString2,
|
---|
301 | int, iMaxLength)
|
---|
302 | {
|
---|
303 | return lstrcpynW(lpString1,lpString2,iMaxLength);
|
---|
304 | }
|
---|
305 |
|
---|
306 | /*****************************************************************************
|
---|
307 | * Name : StrNCpyW
|
---|
308 | * Purpose :
|
---|
309 | * Parameters:
|
---|
310 | * Variables :
|
---|
311 | * Result :
|
---|
312 | * Remark : SHELL32.316 - used by winfile.exe
|
---|
313 | * Status : UNTESTED UNKNOWN STUB
|
---|
314 | *
|
---|
315 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
316 | *****************************************************************************/
|
---|
317 |
|
---|
318 | ODINFUNCTION2(LPWSTR, StrNCpyW,
|
---|
319 | LPWSTR, lpString1,
|
---|
320 | LPWSTR, lpString2)
|
---|
321 | {
|
---|
322 | return lstrcpyW(lpString1,lpString2);
|
---|
323 | }
|
---|
324 |
|
---|
325 |
|
---|
326 | /*****************************************************************************
|
---|
327 | * Name : InternalExtractIconListA
|
---|
328 | * Purpose :
|
---|
329 | * Parameters: ???
|
---|
330 | * Variables :
|
---|
331 | * Result :
|
---|
332 | * Remark : SHELL32.221 - used by progman.exe
|
---|
333 | * Status : UNTESTED UNKNOWN STUB
|
---|
334 | *
|
---|
335 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
336 | *****************************************************************************/
|
---|
337 |
|
---|
338 | ODINPROCEDURE0(InternalExtractIconListA)
|
---|
339 | {
|
---|
340 | dprintf(("SHELL32: undoc InternalExtractIconListA \n"));
|
---|
341 | }
|
---|
342 |
|
---|
343 | /*****************************************************************************
|
---|
344 | * Name : InternalExtractIconListW
|
---|
345 | * Purpose :
|
---|
346 | * Parameters: ???
|
---|
347 | * Variables :
|
---|
348 | * Result :
|
---|
349 | * Remark : SHELL32.222 - used by progman.exe
|
---|
350 | * Status : UNTESTED UNKNOWN STUB
|
---|
351 | *
|
---|
352 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
353 | *****************************************************************************/
|
---|
354 |
|
---|
355 | ODINPROCEDURE0(InternalExtractIconListW)
|
---|
356 | {
|
---|
357 | dprintf(("SHELL32: undoc InternalExtractIconListW\n"));
|
---|
358 | }
|
---|
359 |
|
---|
360 | /*****************************************************************************
|
---|
361 | * Name : ExtractIconResInfoA
|
---|
362 | * Purpose :
|
---|
363 | * Parameters: ???
|
---|
364 | * Variables :
|
---|
365 | * Result :
|
---|
366 | * Remark : SHELL32.192 - used by progman.exe
|
---|
367 | * Status : UNTESTED UNKNOWN STUB
|
---|
368 | *
|
---|
369 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
370 | *****************************************************************************/
|
---|
371 |
|
---|
372 | ODINPROCEDURE0(ExtractIconResInfoA)
|
---|
373 | {
|
---|
374 | dprintf(("SHELL32: undoc ExtractIconResInfoA\n"));
|
---|
375 | }
|
---|
376 |
|
---|
377 | /*****************************************************************************
|
---|
378 | * Name : ExtractIconResInfoW
|
---|
379 | * Purpose :
|
---|
380 | * Parameters: ???
|
---|
381 | * Variables :
|
---|
382 | * Result :
|
---|
383 | * Remark : SHELL32.193 - used by progman.exe
|
---|
384 | * Status : UNTESTED UNKNOWN STUB
|
---|
385 | *
|
---|
386 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
387 | *****************************************************************************/
|
---|
388 |
|
---|
389 | ODINPROCEDURE0(ExtractIconResInfoW)
|
---|
390 | {
|
---|
391 | dprintf(("SHELL32: undoc ExtractIconResInfoW\n"));
|
---|
392 | }
|
---|
393 |
|
---|
394 | /*************************************************************************
|
---|
395 | * FindEnvironmentString [SHELL.38]
|
---|
396 | *
|
---|
397 | * Returns a pointer into the DOS environment... Ugh.
|
---|
398 | */
|
---|
399 | LPSTR SHELL_FindStringA(LPSTR lpEnv, LPCSTR entry)
|
---|
400 | { UINT16 l;
|
---|
401 |
|
---|
402 | //TRACE_(shell)("\n");
|
---|
403 |
|
---|
404 | l = strlen(entry);
|
---|
405 | for( ; *lpEnv ; lpEnv+=strlen(lpEnv)+1 )
|
---|
406 | { if( lstrncmpiA(lpEnv, entry, l) )
|
---|
407 | continue;
|
---|
408 | if( !*(lpEnv+l) )
|
---|
409 | return (lpEnv + l); /* empty entry */
|
---|
410 | else if ( *(lpEnv+l)== '=' )
|
---|
411 | return (lpEnv + l + 1);
|
---|
412 | }
|
---|
413 | return NULL;
|
---|
414 | }
|
---|
415 |
|
---|
416 |
|
---|
417 | /*****************************************************************************
|
---|
418 | * Name : CheckEscapesA
|
---|
419 | * Purpose :
|
---|
420 | * Parameters: ???
|
---|
421 | * Variables :
|
---|
422 | * Result :
|
---|
423 | * Remark : SHELL32.3 - used by progman.exe
|
---|
424 | * Status : UNTESTED UNKNOWN STUB
|
---|
425 | *
|
---|
426 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
427 | *****************************************************************************/
|
---|
428 |
|
---|
429 | ODINPROCEDURE2(CheckEscapesA,
|
---|
430 | DWORD, x1,
|
---|
431 | DWORD, x2)
|
---|
432 | {
|
---|
433 | dprintf(("SHELL32: undoc CheckEscapesA\n"));
|
---|
434 | }
|
---|
435 |
|
---|
436 | /*****************************************************************************
|
---|
437 | * Name : CheckEscapesW
|
---|
438 | * Purpose :
|
---|
439 | * Parameters: ???
|
---|
440 | * Variables :
|
---|
441 | * Result :
|
---|
442 | * Remark : SHELL32.6 - used by progman.exe
|
---|
443 | * Status : UNTESTED UNKNOWN STUB
|
---|
444 | *
|
---|
445 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
446 | *****************************************************************************/
|
---|
447 |
|
---|
448 | ODINPROCEDURE2(CheckEscapesW,
|
---|
449 | DWORD, x1,
|
---|
450 | DWORD, x2)
|
---|
451 | {
|
---|
452 | dprintf(("SHELL32: undoc CheckEscapesW\n"));
|
---|
453 | }
|
---|
454 |
|
---|
455 | /*****************************************************************************
|
---|
456 | * Name : DuplicateIcon
|
---|
457 | * Purpose :
|
---|
458 | * Parameters: ???
|
---|
459 | * Variables :
|
---|
460 | * Result :
|
---|
461 | * Remark : SHELL32.138 - used by progman.exe
|
---|
462 | * Status : UNTESTED UNKNOWN STUB
|
---|
463 | *
|
---|
464 | * Author : Christoph Bratschi [Fri, 1999/08/6 19:00]
|
---|
465 | *****************************************************************************/
|
---|
466 |
|
---|
467 | ODINFUNCTION1(DWORD, DuplicateIcon,
|
---|
468 | DWORD, x1)
|
---|
469 | {
|
---|
470 | dprintf(("SHELL32: undoc DuplicateIcon\n"));
|
---|
471 |
|
---|
472 | return 0;
|
---|
473 | }
|
---|
474 |
|
---|