1 | /* $Id: misc.cpp,v 1.1 1999-06-23 22:17:52 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 <os2win.h>
|
---|
18 | #include <shellapi.h>
|
---|
19 | #include "shell32.h"
|
---|
20 | #include <misc.h>
|
---|
21 | #include <string.h>
|
---|
22 |
|
---|
23 |
|
---|
24 | /*****************************************************************************
|
---|
25 | * Types & Defines *
|
---|
26 | *****************************************************************************/
|
---|
27 |
|
---|
28 |
|
---|
29 | /*****************************************************************************
|
---|
30 | * Name : LPWSTR* WIN32API CommandLineToArgvW
|
---|
31 | * Purpose :
|
---|
32 | * Parameters:
|
---|
33 | * Variables :
|
---|
34 | * Result :
|
---|
35 | * Remark :
|
---|
36 | * Status : UNTESTED STUB
|
---|
37 | *
|
---|
38 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
39 | *****************************************************************************/
|
---|
40 |
|
---|
41 | LPWSTR * WIN32API CommandLineToArgvW(LPCWSTR lpCmdLine,
|
---|
42 | int *pNumArgs)
|
---|
43 | {
|
---|
44 | LPWSTR *argv, s, t;
|
---|
45 | int i;
|
---|
46 |
|
---|
47 | dprintf(("SHELL32: CommandLineToArgvW(%s,%08xh)\n",
|
---|
48 | lpCmdLine,
|
---|
49 | pNumArgs));
|
---|
50 |
|
---|
51 | s = (LPWSTR)lpCmdLine;
|
---|
52 | i = 0;
|
---|
53 | while (*s) {
|
---|
54 | /* space */
|
---|
55 | if (*s==0x0020) {
|
---|
56 | i++;
|
---|
57 | s++;
|
---|
58 | while (*s && *s==0x0020)
|
---|
59 | s++;
|
---|
60 | continue;
|
---|
61 | }
|
---|
62 | s++;
|
---|
63 | }
|
---|
64 | argv = (LPWSTR *)LocalAlloc(LPTR, sizeof(LPWSTR)*(i+1));
|
---|
65 | s = t = (LPWSTR)lpCmdLine;
|
---|
66 | i = 0;
|
---|
67 | while(*s) {
|
---|
68 | if (*s==0x0020) {
|
---|
69 | *s=0;
|
---|
70 | argv[i++] = t;
|
---|
71 | *s=0x0020;
|
---|
72 | while (*s && *s==0x0020)
|
---|
73 | s++;
|
---|
74 | if(*s)
|
---|
75 | t=s+1;
|
---|
76 | else t=s;
|
---|
77 | continue;
|
---|
78 | }
|
---|
79 | s++;
|
---|
80 | }
|
---|
81 | if(*t)
|
---|
82 | argv[i++] = t;
|
---|
83 |
|
---|
84 | argv[i]=NULL;
|
---|
85 | *pNumArgs = i;
|
---|
86 | return argv;
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | /*****************************************************************************
|
---|
91 | * Name : HICON WIN32API ExtractIconA
|
---|
92 | * Purpose :
|
---|
93 | * Parameters:
|
---|
94 | * Variables :
|
---|
95 | * Result :
|
---|
96 | * Remark :
|
---|
97 | * Status : UNTESTED STUB
|
---|
98 | *
|
---|
99 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
100 | *****************************************************************************/
|
---|
101 |
|
---|
102 | HICON WIN32API ExtractIconA(HINSTANCE hInst,
|
---|
103 | LPCSTR lpszExeFileName,
|
---|
104 | UINT nIconIndex)
|
---|
105 | {
|
---|
106 | dprintf(("SHELL32: ExtractIconA(%08xh,%s,%08xh) not implemented.\n",
|
---|
107 | hInst,
|
---|
108 | lpszExeFileName,
|
---|
109 | nIconIndex));
|
---|
110 |
|
---|
111 | return(NULL);
|
---|
112 | }
|
---|
113 |
|
---|
114 |
|
---|
115 | /*****************************************************************************
|
---|
116 | * Name : HICON WIN32API ExtractIconW
|
---|
117 | * Purpose :
|
---|
118 | * Parameters:
|
---|
119 | * Variables :
|
---|
120 | * Result :
|
---|
121 | * Remark :
|
---|
122 | * Status : UNTESTED STUB
|
---|
123 | *
|
---|
124 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
125 | *****************************************************************************/
|
---|
126 |
|
---|
127 | HICON WIN32API ExtractIconW(HINSTANCE hInst,
|
---|
128 | LPCWSTR lpszExeFileName,
|
---|
129 | UINT nIconIndex)
|
---|
130 | {
|
---|
131 | HICON hicon = NULL;
|
---|
132 | char *astring = UnicodeToAsciiString((LPWSTR)lpszExeFileName);
|
---|
133 |
|
---|
134 | dprintf(("SHELL32: ExtractIconW(%08xh,%s,%08xh) not implemented.\n",
|
---|
135 | hInst,
|
---|
136 | lpszExeFileName,
|
---|
137 | nIconIndex));
|
---|
138 |
|
---|
139 |
|
---|
140 | FreeAsciiString(astring);
|
---|
141 | return(hicon);
|
---|
142 | }
|
---|
143 |
|
---|
144 |
|
---|
145 | /*****************************************************************************
|
---|
146 | * Name : HICON WIN32API ExtractIconExA
|
---|
147 | * Purpose :
|
---|
148 | * Parameters:
|
---|
149 | * Variables :
|
---|
150 | * Result :
|
---|
151 | * Remark :
|
---|
152 | * Status : UNTESTED STUB
|
---|
153 | *
|
---|
154 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
155 | *****************************************************************************/
|
---|
156 |
|
---|
157 | DWORD WIN32API ExtractIconExA(LPCSTR lpszFile,
|
---|
158 | int nIconIndex,
|
---|
159 | HICON *phiconLarge,
|
---|
160 | HICON *phiconSmall,
|
---|
161 | UINT nIcons)
|
---|
162 | {
|
---|
163 | dprintf(("SHELL32: ExtractIconExA(%s,%08xh,%08xh,%08xh,%u) not implemented.\n",
|
---|
164 | lpszFile,
|
---|
165 | nIconIndex,
|
---|
166 | phiconLarge,
|
---|
167 | phiconSmall,
|
---|
168 | nIcons));
|
---|
169 |
|
---|
170 | return (0);
|
---|
171 | }
|
---|
172 |
|
---|
173 |
|
---|
174 | /*****************************************************************************
|
---|
175 | * Name : HICON WIN32API ExtractIconExW
|
---|
176 | * Purpose :
|
---|
177 | * Parameters:
|
---|
178 | * Variables :
|
---|
179 | * Result :
|
---|
180 | * Remark :
|
---|
181 | * Status : UNTESTED STUB
|
---|
182 | *
|
---|
183 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
184 | *****************************************************************************/
|
---|
185 |
|
---|
186 | HICON WIN32API ExtractIconExW(LPCWSTR lpszFile,
|
---|
187 | int nIconIndex,
|
---|
188 | HICON *phiconLarge,
|
---|
189 | HICON *phiconSmall,
|
---|
190 | UINT nIcons)
|
---|
191 | {
|
---|
192 | dprintf(("SHELL32: ExtractIconExW(%s,%08xh,%08xh,%08xh,%u) not implemented.\n",
|
---|
193 | lpszFile,
|
---|
194 | nIconIndex,
|
---|
195 | phiconLarge,
|
---|
196 | phiconSmall,
|
---|
197 | nIcons));
|
---|
198 |
|
---|
199 | return (0);
|
---|
200 | }
|
---|
201 |
|
---|
202 |
|
---|
203 | /*****************************************************************************
|
---|
204 | * Name : HINSTANCE WIN32API FindExecutableA
|
---|
205 | * Purpose :
|
---|
206 | * Parameters:
|
---|
207 | * Variables :
|
---|
208 | * Result :
|
---|
209 | * Remark :
|
---|
210 | * Status : UNTESTED STUB
|
---|
211 | *
|
---|
212 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
213 | *****************************************************************************/
|
---|
214 |
|
---|
215 | HINSTANCE WIN32API FindExecutableA(LPCSTR lpszFile,
|
---|
216 | LPCSTR lpszDir,
|
---|
217 | LPTSTR lpszResult)
|
---|
218 | {
|
---|
219 | dprintf(("SHELL32: FindExecutableA (%s,%s,%s) not implemented.\n",
|
---|
220 | lpszFile,
|
---|
221 | lpszDir,
|
---|
222 | lpszResult));
|
---|
223 |
|
---|
224 | return(NULL);
|
---|
225 | }
|
---|
226 |
|
---|
227 |
|
---|
228 | /*****************************************************************************
|
---|
229 | * Name : HINSTANCE WIN32API FindExecutableW
|
---|
230 | * Purpose :
|
---|
231 | * Parameters:
|
---|
232 | * Variables :
|
---|
233 | * Result :
|
---|
234 | * Remark :
|
---|
235 | * Status : UNTESTED STUB
|
---|
236 | *
|
---|
237 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
238 | *****************************************************************************/
|
---|
239 |
|
---|
240 | HINSTANCE WIN32API FindExecutableW(LPCWSTR lpszFile,
|
---|
241 | LPCWSTR lpszDir,
|
---|
242 | LPWSTR lpszResult)
|
---|
243 | {
|
---|
244 | dprintf(("SHELL32: FindExecutableW (%s,%s,%s) not implemented.\n",
|
---|
245 | lpszFile,
|
---|
246 | lpszDir,
|
---|
247 | lpszResult));
|
---|
248 |
|
---|
249 | return(NULL);
|
---|
250 | }
|
---|
251 |
|
---|
252 |
|
---|
253 | /*****************************************************************************
|
---|
254 | * Name : HICON WIN32API ExtractAssociatedIconA
|
---|
255 | * Purpose : Return icon for given file (either from file itself or from associated
|
---|
256 | * executable) and patch parameters if needed.
|
---|
257 | * Parameters:
|
---|
258 | * Variables :
|
---|
259 | * Result :
|
---|
260 | * Remark : SHELL.36
|
---|
261 | * Status : UNTESTED STUB
|
---|
262 | *
|
---|
263 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
264 | *****************************************************************************/
|
---|
265 |
|
---|
266 | HICON WIN32API ExtractAssociatedIconA(HINSTANCE hInst,
|
---|
267 | LPSTR lpIconPath,
|
---|
268 | LPWORD lpiIcon)
|
---|
269 | {
|
---|
270 | HICON hIcon;
|
---|
271 |
|
---|
272 | dprintf(("SHELL32: ExtractAssociatedIconA(%08xh,%s,%08xh)\n",
|
---|
273 | hInst,
|
---|
274 | lpIconPath,
|
---|
275 | lpiIcon));
|
---|
276 |
|
---|
277 | hIcon = ExtractIconA(hInst,
|
---|
278 | lpIconPath,
|
---|
279 | *lpiIcon);
|
---|
280 |
|
---|
281 | if( hIcon < 2 )
|
---|
282 | {
|
---|
283 | if( hIcon == 1 ) /* no icons found in given file */
|
---|
284 | {
|
---|
285 | char tempPath[0x80];
|
---|
286 | UINT uRet = FindExecutableA(lpIconPath,
|
---|
287 | NULL,
|
---|
288 | tempPath);
|
---|
289 |
|
---|
290 | if(uRet > 32 && tempPath[0])
|
---|
291 | {
|
---|
292 | strcpy(lpIconPath,tempPath);
|
---|
293 | hIcon = ExtractIconA(hInst,
|
---|
294 | lpIconPath,
|
---|
295 | *lpiIcon);
|
---|
296 | if( hIcon > 2 )
|
---|
297 | return hIcon;
|
---|
298 | }
|
---|
299 | else
|
---|
300 | hIcon = 0;
|
---|
301 | }
|
---|
302 |
|
---|
303 | if( hIcon == 1 )
|
---|
304 | *lpiIcon = 2; /* MSDOS icon - we found .exe but no icons in it */
|
---|
305 | else
|
---|
306 | *lpiIcon = 6; /* generic icon - found nothing */
|
---|
307 |
|
---|
308 | /* @@@PH - how is this supposed to work ?
|
---|
309 | GetModuleFileNameA(hInst,
|
---|
310 | lpIconPath,
|
---|
311 | 0x80);
|
---|
312 | hIcon = LoadIconA(hInst,
|
---|
313 | *lpiIcon);
|
---|
314 | */
|
---|
315 | }
|
---|
316 | return hIcon;
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 | /*****************************************************************************
|
---|
321 | * Name : HICON WIN32API ExtractAssociatedIconW
|
---|
322 | * Purpose : Return icon for given file (either from file itself or from associated
|
---|
323 | * executable) and patch parameters if needed.
|
---|
324 | * Parameters:
|
---|
325 | * Variables :
|
---|
326 | * Result :
|
---|
327 | * Remark : SHELL.36
|
---|
328 | * Status : UNTESTED STUB
|
---|
329 | *
|
---|
330 | * Author : Patrick Haller [Sat, 1998/07/11 11:55]
|
---|
331 | *****************************************************************************/
|
---|
332 |
|
---|
333 | HICON WIN32API ExtractAssociatedIconW(HINSTANCE hInst,
|
---|
334 | LPWSTR lpIconPath,
|
---|
335 | LPWORD lpiIcon)
|
---|
336 | {
|
---|
337 | LPSTR lpIconPathAscii = UnicodeToAsciiString(lpIconPath);
|
---|
338 | HICON hIcon;
|
---|
339 |
|
---|
340 | dprintf(("SHELL32: ExtractAssociatedIconW(%08xh,%s,%08xh)\n",
|
---|
341 | hInst,
|
---|
342 | lpIconPathAscii,
|
---|
343 | lpiIcon));
|
---|
344 |
|
---|
345 | hIcon = ExtractAssociatedIconA(hInst,
|
---|
346 | lpIconPathAscii,
|
---|
347 | lpiIcon);
|
---|
348 |
|
---|
349 | FreeAsciiString(lpIconPathAscii);
|
---|
350 |
|
---|
351 | return (hIcon);
|
---|
352 | }
|
---|
353 |
|
---|