1 | /* $Id: shell.cpp,v 1.4 2000-01-27 21:50:45 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 SHELL32 for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | * Shell Library Functions
|
---|
10 | *
|
---|
11 | * 1998 Marcus Meissner
|
---|
12 | */
|
---|
13 |
|
---|
14 |
|
---|
15 | /*****************************************************************************
|
---|
16 | * Includes *
|
---|
17 | *****************************************************************************/
|
---|
18 |
|
---|
19 | #include <odin.h>
|
---|
20 | #include <odinwrap.h>
|
---|
21 | #include <os2sel.h>
|
---|
22 |
|
---|
23 | #include <assert.h>
|
---|
24 | #include <stdlib.h>
|
---|
25 | #include <string.h>
|
---|
26 | //#include <unistd.h>
|
---|
27 | #include <ctype.h>
|
---|
28 |
|
---|
29 | #define ICOM_CINTERFACE 1
|
---|
30 | #define CINTERFACE 1
|
---|
31 |
|
---|
32 | #include <winbase.h>
|
---|
33 | #include <winuser.h>
|
---|
34 | //#include "wine/shell16.h"
|
---|
35 | #include "winerror.h"
|
---|
36 | //#include "file.h"
|
---|
37 | #include "heap.h"
|
---|
38 | #include "ldt.h"
|
---|
39 | #include "module.h"
|
---|
40 | #include "neexe.h"
|
---|
41 | #include "dlgs.h"
|
---|
42 | #include "cursoricon.h"
|
---|
43 | #include "shellapi.h"
|
---|
44 | #include "shlobj.h"
|
---|
45 | #include "debugtools.h"
|
---|
46 | #include "winreg.h"
|
---|
47 | //#include "syslevel.h"
|
---|
48 | #include "imagelist.h"
|
---|
49 | #include "shell32_main.h"
|
---|
50 |
|
---|
51 | #include <heapstring.h>
|
---|
52 | #include <misc.h>
|
---|
53 |
|
---|
54 |
|
---|
55 | /*****************************************************************************
|
---|
56 | * Implementation *
|
---|
57 | *****************************************************************************/
|
---|
58 |
|
---|
59 | ODINDEBUGCHANNEL(SHELL32-SHELL)
|
---|
60 |
|
---|
61 |
|
---|
62 | /* .ICO file ICONDIR definitions */
|
---|
63 |
|
---|
64 | #include "pshpack1.h"
|
---|
65 |
|
---|
66 | typedef struct
|
---|
67 | {
|
---|
68 | BYTE bWidth; /* Width, in pixels, of the image */
|
---|
69 | BYTE bHeight; /* Height, in pixels, of the image */
|
---|
70 | BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */
|
---|
71 | BYTE bReserved; /* Reserved ( must be 0) */
|
---|
72 | WORD wPlanes; /* Color Planes */
|
---|
73 | WORD wBitCount; /* Bits per pixel */
|
---|
74 | DWORD dwBytesInRes; /* How many bytes in this resource? */
|
---|
75 | DWORD dwImageOffset; /* Where in the file is this image? */
|
---|
76 | } icoICONDIRENTRY, *LPicoICONDIRENTRY;
|
---|
77 |
|
---|
78 | typedef struct
|
---|
79 | {
|
---|
80 | WORD idReserved; /* Reserved (must be 0) */
|
---|
81 | WORD idType; /* Resource Type (1 for icons) */
|
---|
82 | WORD idCount; /* How many images? */
|
---|
83 | icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */
|
---|
84 | } icoICONDIR, *LPicoICONDIR;
|
---|
85 |
|
---|
86 | #include "poppack.h"
|
---|
87 |
|
---|
88 | static const char* lpstrMsgWndCreated = "OTHERWINDOWCREATED";
|
---|
89 | static const char* lpstrMsgWndDestroyed = "OTHERWINDOWDESTROYED";
|
---|
90 | static const char* lpstrMsgShellActivate = "ACTIVATESHELLWINDOW";
|
---|
91 |
|
---|
92 | static HWND16 SHELL_hWnd = 0;
|
---|
93 | static HHOOK SHELL_hHook = 0;
|
---|
94 | static UINT16 uMsgWndCreated = 0;
|
---|
95 | static UINT16 uMsgWndDestroyed = 0;
|
---|
96 | static UINT16 uMsgShellActivate = 0;
|
---|
97 | HINSTANCE16 SHELL_hInstance = 0;
|
---|
98 | HINSTANCE SHELL_hInstance32;
|
---|
99 | static int SHELL_Attach = 0;
|
---|
100 |
|
---|
101 |
|
---|
102 | /*************************************************************************
|
---|
103 | * DragAcceptFiles32 [SHELL32.54]
|
---|
104 | */
|
---|
105 |
|
---|
106 | //SvL: DON'T USE ODINFUNCTION MACRO'S HERE; SetWindowLong (style) sends messages
|
---|
107 | // to the win32 app!!!! (FS messed up)
|
---|
108 | void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
|
---|
109 | {
|
---|
110 | LONG exstyle;
|
---|
111 |
|
---|
112 | dprintf(("DragAcceptFiles %x %d", hWnd, b));
|
---|
113 | if( !IsWindow(hWnd) )
|
---|
114 | return;
|
---|
115 | exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
|
---|
116 | if (b)exstyle |= WS_EX_ACCEPTFILES;
|
---|
117 | else exstyle &= ~WS_EX_ACCEPTFILES;
|
---|
118 | SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
|
---|
119 | }
|
---|
120 |
|
---|
121 | /*************************************************************************
|
---|
122 | * SHELL_DragQueryFile [internal]
|
---|
123 | *
|
---|
124 | */
|
---|
125 | static UINT SHELL_DragQueryFile(LPSTR lpDrop, LPWSTR lpwDrop, UINT lFile,
|
---|
126 | LPSTR lpszFile, LPWSTR lpszwFile, UINT lLength)
|
---|
127 | {
|
---|
128 | UINT i;
|
---|
129 |
|
---|
130 | i = 0;
|
---|
131 | if (lpDrop) {
|
---|
132 | while (i++ < lFile) {
|
---|
133 | while (*lpDrop++); /* skip filename */
|
---|
134 | if (!*lpDrop)
|
---|
135 | return (lFile == 0xFFFFFFFF) ? i : 0;
|
---|
136 | }
|
---|
137 | }
|
---|
138 | if (lpwDrop) {
|
---|
139 | while (i++ < lFile) {
|
---|
140 | while (*lpwDrop++); /* skip filename */
|
---|
141 | if (!*lpwDrop)
|
---|
142 | return (lFile == 0xFFFFFFFF) ? i : 0;
|
---|
143 | }
|
---|
144 | }
|
---|
145 |
|
---|
146 | if (lpDrop) i = lstrlenA(lpDrop);
|
---|
147 | if (lpwDrop) i = lstrlenW(lpwDrop);
|
---|
148 | i++;
|
---|
149 | if (!lpszFile && !lpszwFile) {
|
---|
150 | return i; /* needed buffer size */
|
---|
151 | }
|
---|
152 | i = (lLength > i) ? i : lLength;
|
---|
153 | if (lpszFile) {
|
---|
154 | if (lpDrop) lstrcpynA (lpszFile, lpDrop, i);
|
---|
155 | else lstrcpynWtoA(lpszFile, lpwDrop, i);
|
---|
156 | } else {
|
---|
157 | if (lpDrop) lstrcpynAtoW(lpszwFile, lpDrop, i);
|
---|
158 | else lstrcpynW (lpszwFile, lpwDrop, i);
|
---|
159 | }
|
---|
160 | return i;
|
---|
161 | }
|
---|
162 |
|
---|
163 | /*************************************************************************
|
---|
164 | * DragQueryFile32A [SHELL32.81] [shell32.82]
|
---|
165 | */
|
---|
166 |
|
---|
167 | ODINFUNCTION4(UINT, DragQueryFileA, HDROP, hDrop,
|
---|
168 | UINT, lFile,
|
---|
169 | LPSTR, lpszFile,
|
---|
170 | UINT, lLength)
|
---|
171 | { /* hDrop is a global memory block allocated with GMEM_SHARE
|
---|
172 | * with DROPFILESTRUCT as a header and filenames following
|
---|
173 | * it, zero length filename is in the end */
|
---|
174 |
|
---|
175 | LPDROPFILESTRUCT lpDropFileStruct;
|
---|
176 | LPSTR lpCurrent;
|
---|
177 | UINT i;
|
---|
178 |
|
---|
179 | lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
|
---|
180 | if(!lpDropFileStruct)
|
---|
181 | return 0;
|
---|
182 |
|
---|
183 | lpCurrent = (LPSTR) lpDropFileStruct + lpDropFileStruct->lSize;
|
---|
184 | i = SHELL_DragQueryFile(lpCurrent, NULL, lFile, lpszFile, NULL, lLength);
|
---|
185 | GlobalUnlock(hDrop);
|
---|
186 | return i;
|
---|
187 | }
|
---|
188 |
|
---|
189 | /*************************************************************************
|
---|
190 | * DragQueryFile32W [shell32.133]
|
---|
191 | */
|
---|
192 | ODINFUNCTION4(UINT, DragQueryFileW, HDROP, hDrop,
|
---|
193 | UINT, lFile,
|
---|
194 | LPWSTR, lpszwFile,
|
---|
195 | UINT, lLength)
|
---|
196 | {
|
---|
197 | LPDROPFILESTRUCT lpDropFileStruct;
|
---|
198 | LPWSTR lpwCurrent;
|
---|
199 | UINT i;
|
---|
200 |
|
---|
201 | lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
|
---|
202 | if(!lpDropFileStruct)
|
---|
203 | return 0;
|
---|
204 |
|
---|
205 | lpwCurrent = (LPWSTR) lpDropFileStruct + lpDropFileStruct->lSize;
|
---|
206 | i = SHELL_DragQueryFile(NULL, lpwCurrent, lFile, NULL, lpszwFile,lLength);
|
---|
207 | GlobalUnlock(hDrop);
|
---|
208 | return i;
|
---|
209 | }
|
---|
210 |
|
---|
211 |
|
---|
212 | /*****************************************************************************
|
---|
213 | * Name : UINT DragQueryFileAorW
|
---|
214 | * Purpose :
|
---|
215 | * Parameters: HDROP hDrop - drop structure handle
|
---|
216 | * UINT iFile - index of file to query
|
---|
217 | * LPTSTR lpszFile - target buffer
|
---|
218 | * UINT cch - target buffer size
|
---|
219 | * Variables :
|
---|
220 | * Result :
|
---|
221 | * Remark :
|
---|
222 | * Status : UNTESTED STUB
|
---|
223 | *
|
---|
224 | * Author : Patrick Haller [Tue, 1999/06/09 20:00]
|
---|
225 | *****************************************************************************/
|
---|
226 |
|
---|
227 | ODINFUNCTION4(UINT, DragQueryFileAorW,
|
---|
228 | HDROP, hDrop,
|
---|
229 | UINT, iFile,
|
---|
230 | LPTSTR, lpszFile,
|
---|
231 | UINT, cch)
|
---|
232 | {
|
---|
233 | // @@@PH maybe they want automatic determination here
|
---|
234 | if (VERSION_OsIsUnicode())
|
---|
235 | return DragQueryFileW(hDrop, iFile, (LPWSTR)lpszFile, cch);
|
---|
236 | else
|
---|
237 | return DragQueryFileA(hDrop, iFile, lpszFile, cch);
|
---|
238 | }
|
---|
239 |
|
---|
240 |
|
---|
241 | /*************************************************************************
|
---|
242 | * DragFinish32 [SHELL32.80]
|
---|
243 | */
|
---|
244 | ODINPROCEDURE1(DragFinish, HDROP, h)
|
---|
245 | {
|
---|
246 | GlobalFree((HGLOBAL)h);
|
---|
247 | }
|
---|
248 |
|
---|
249 |
|
---|
250 | /*************************************************************************
|
---|
251 | * DragQueryPoint32 [SHELL32.135]
|
---|
252 | */
|
---|
253 | ODINFUNCTION2(BOOL, DragQueryPoint,
|
---|
254 | HDROP, hDrop,
|
---|
255 | POINT*, p)
|
---|
256 | {
|
---|
257 | LPDROPFILESTRUCT lpDropFileStruct;
|
---|
258 | BOOL bRet;
|
---|
259 |
|
---|
260 | lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
|
---|
261 |
|
---|
262 | memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT));
|
---|
263 | bRet = lpDropFileStruct->fInNonClientArea;
|
---|
264 |
|
---|
265 | GlobalUnlock(hDrop);
|
---|
266 | return bRet;
|
---|
267 | }
|
---|
268 |
|
---|
269 | /*************************************************************************
|
---|
270 | * SHELL_FindExecutable [Internal]
|
---|
271 | *
|
---|
272 | * Utility for code sharing between FindExecutable and ShellExecute
|
---|
273 | */
|
---|
274 | HINSTANCE SHELL_FindExecutable( LPCSTR lpFile,
|
---|
275 | LPCSTR lpOperation,
|
---|
276 | LPSTR lpResult)
|
---|
277 | { char *extension = NULL; /* pointer to file extension */
|
---|
278 | char tmpext[5]; /* local copy to mung as we please */
|
---|
279 | char filetype[256]; /* registry name for this filetype */
|
---|
280 | LONG filetypelen=256; /* length of above */
|
---|
281 | char command[256]; /* command from registry */
|
---|
282 | LONG commandlen=256; /* This is the most DOS can handle :) */
|
---|
283 | char buffer[256]; /* Used to GetProfileString */
|
---|
284 | HINSTANCE retval=31; /* default - 'No association was found' */
|
---|
285 | char *tok; /* token pointer */
|
---|
286 | int i; /* random counter */
|
---|
287 | char xlpFile[256]; /* result of SearchPath */
|
---|
288 |
|
---|
289 | dprintf(("SHELL32:SHELL:SHELL_FindExecutable(%s,%s,%08xh)\n",
|
---|
290 | lpFile,
|
---|
291 | lpOperation,
|
---|
292 | lpResult));
|
---|
293 |
|
---|
294 | lpResult[0]='\0'; /* Start off with an empty return string */
|
---|
295 |
|
---|
296 | /* trap NULL parameters on entry */
|
---|
297 | if (( lpFile == NULL ) || ( lpResult == NULL ) || ( lpOperation == NULL ))
|
---|
298 | { dprintf(("SHELL32:SHELL:SHELL_FindExecutable(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
|
---|
299 | lpFile, lpOperation, lpResult));
|
---|
300 | return 2; /* File not found. Close enough, I guess. */
|
---|
301 | }
|
---|
302 |
|
---|
303 | if (SearchPathA( NULL, lpFile,".exe",sizeof(xlpFile),xlpFile,NULL))
|
---|
304 | { dprintf(("SHELL32:SHELL:SHELL_FindExecutable(SearchPath32A returned non-zero\n"));
|
---|
305 | lpFile = xlpFile;
|
---|
306 | }
|
---|
307 |
|
---|
308 | /* First thing we need is the file's extension */
|
---|
309 | extension = strrchr( xlpFile, '.' ); /* Assume last "." is the one; */
|
---|
310 | /* File->Run in progman uses */
|
---|
311 | /* .\FILE.EXE :( */
|
---|
312 | dprintf(("SHELL32:SHELL:SHELL_FindExecutable(xlpFile=%s,extension=%s)\n",
|
---|
313 | xlpFile, extension));
|
---|
314 |
|
---|
315 | if ((extension == NULL) || (extension == &xlpFile[strlen(xlpFile)]))
|
---|
316 | { dprintf(("SHELL32:SHELL:SHELL_FindExecutable Returning 31 - No association\n"));
|
---|
317 | return 31; /* no association */
|
---|
318 | }
|
---|
319 |
|
---|
320 | /* Make local copy & lowercase it for reg & 'programs=' lookup */
|
---|
321 | lstrcpynA( tmpext, extension, 5 );
|
---|
322 | CharLowerA( tmpext );
|
---|
323 |
|
---|
324 |
|
---|
325 | dprintf(("SHELL32:SHELL:SHELL_FindExecutable(%s file)\n", tmpext));
|
---|
326 |
|
---|
327 | /* Three places to check: */
|
---|
328 | /* 1. win.ini, [windows], programs (NB no leading '.') */
|
---|
329 | /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
|
---|
330 | /* 3. win.ini, [extensions], extension (NB no leading '.' */
|
---|
331 | /* All I know of the order is that registry is checked before */
|
---|
332 | /* extensions; however, it'd make sense to check the programs */
|
---|
333 | /* section first, so that's what happens here. */
|
---|
334 |
|
---|
335 | /* See if it's a program - if GetProfileString fails, we skip this
|
---|
336 | * section. Actually, if GetProfileString fails, we've probably
|
---|
337 | * got a lot more to worry about than running a program... */
|
---|
338 | if ( GetProfileStringA("windows", "programs", "exe pif bat com",
|
---|
339 | buffer, sizeof(buffer)) > 0 )
|
---|
340 | { for (i=0;i<strlen(buffer); i++) buffer[i]=tolower(buffer[i]);
|
---|
341 |
|
---|
342 | tok = strtok(buffer, " \t"); /* ? */
|
---|
343 | while( tok!= NULL)
|
---|
344 | {
|
---|
345 | if (strcmp(tok, &tmpext[1])==0) /* have to skip the leading "." */
|
---|
346 | {
|
---|
347 | strcpy(lpResult, xlpFile);
|
---|
348 | /* Need to perhaps check that the file has a path
|
---|
349 | * attached */
|
---|
350 | dprintf(("SHELL32:SHELL:SHELL_FindExecutable found %s\n",
|
---|
351 | lpResult));
|
---|
352 | return 33;
|
---|
353 |
|
---|
354 | /* Greater than 32 to indicate success FIXME According to the
|
---|
355 | * docs, I should be returning a handle for the
|
---|
356 | * executable. Does this mean I'm supposed to open the
|
---|
357 | * executable file or something? More RTFM, I guess... */
|
---|
358 | }
|
---|
359 | tok=strtok(NULL, " \t");
|
---|
360 | }
|
---|
361 | }
|
---|
362 |
|
---|
363 | /* Check registry */
|
---|
364 | if (RegQueryValueA( HKEY_CLASSES_ROOT, tmpext, filetype,
|
---|
365 | &filetypelen ) == ERROR_SUCCESS )
|
---|
366 | {
|
---|
367 | filetype[filetypelen]='\0';
|
---|
368 | dprintf(("SHELL32:SHELL:SHELL_FindExecutable(File type: %s)\n",
|
---|
369 | filetype));
|
---|
370 |
|
---|
371 | /* Looking for ...buffer\shell\lpOperation\command */
|
---|
372 | strcat( filetype, "\\shell\\" );
|
---|
373 | strcat( filetype, lpOperation );
|
---|
374 | strcat( filetype, "\\command" );
|
---|
375 |
|
---|
376 | if (RegQueryValueA( HKEY_CLASSES_ROOT, filetype, command,
|
---|
377 | &commandlen ) == ERROR_SUCCESS )
|
---|
378 | {
|
---|
379 | /* Is there a replace() function anywhere? */
|
---|
380 | command[commandlen]='\0';
|
---|
381 | strcpy( lpResult, command );
|
---|
382 | tok=strstr( lpResult, "%1" );
|
---|
383 | if (tok != NULL)
|
---|
384 | {
|
---|
385 | tok[0]='\0'; /* truncate string at the percent */
|
---|
386 | strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
|
---|
387 | tok=strstr( command, "%1" );
|
---|
388 | if ((tok!=NULL) && (strlen(tok)>2))
|
---|
389 | {
|
---|
390 | strcat( lpResult, &tok[2] );
|
---|
391 | }
|
---|
392 | }
|
---|
393 | retval=33; /* FIXME see above */
|
---|
394 | }
|
---|
395 | }
|
---|
396 | else /* Check win.ini */
|
---|
397 | {
|
---|
398 | /* Toss the leading dot */
|
---|
399 | extension++;
|
---|
400 | if ( GetProfileStringA( "extensions", extension, "", command,
|
---|
401 | sizeof(command)) > 0)
|
---|
402 | {
|
---|
403 | if (strlen(command)!=0)
|
---|
404 | {
|
---|
405 | strcpy( lpResult, command );
|
---|
406 | tok=strstr( lpResult, "^" ); /* should be ^.extension? */
|
---|
407 | if (tok != NULL)
|
---|
408 | {
|
---|
409 | tok[0]='\0';
|
---|
410 | strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
|
---|
411 | tok=strstr( command, "^" ); /* see above */
|
---|
412 | if ((tok != NULL) && (strlen(tok)>5))
|
---|
413 | {
|
---|
414 | strcat( lpResult, &tok[5]);
|
---|
415 | }
|
---|
416 | }
|
---|
417 | retval=33; /* FIXME - see above */
|
---|
418 | }
|
---|
419 | }
|
---|
420 | }
|
---|
421 |
|
---|
422 | dprintf(("SHELL32:SHELL:SHELL_FindExecutable (returning %s)\n", lpResult));
|
---|
423 | return retval;
|
---|
424 | }
|
---|
425 |
|
---|
426 |
|
---|
427 | /*************************************************************************
|
---|
428 | * SHELL_GetResourceTable
|
---|
429 | */
|
---|
430 | static DWORD SHELL_GetResourceTable(HFILE hFile,LPBYTE *retptr)
|
---|
431 | { IMAGE_DOS_HEADER mz_header;
|
---|
432 | char magic[4];
|
---|
433 | int size;
|
---|
434 |
|
---|
435 | dprintf(("SHELL32:Shell:SHELL_GetResourceTable(%08xh,%08xh)\n",
|
---|
436 | hFile,
|
---|
437 | retptr));
|
---|
438 |
|
---|
439 | *retptr = NULL;
|
---|
440 | _llseek( hFile, 0, SEEK_SET );
|
---|
441 | if ((_lread(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) || (mz_header.e_magic != IMAGE_DOS_SIGNATURE))
|
---|
442 | { /* .ICO file ? */
|
---|
443 | if (mz_header.e_cblp == 1)
|
---|
444 | { /* ICONHEADER.idType, must be 1 */
|
---|
445 | *retptr = (LPBYTE)-1;
|
---|
446 | return 1;
|
---|
447 | }
|
---|
448 | else
|
---|
449 | return 0; /* failed */
|
---|
450 | }
|
---|
451 | _llseek( hFile, mz_header.e_lfanew, SEEK_SET );
|
---|
452 |
|
---|
453 | if (_lread( hFile, magic, sizeof(magic) ) != sizeof(magic))
|
---|
454 | return 0;
|
---|
455 |
|
---|
456 | _llseek( hFile, mz_header.e_lfanew, SEEK_SET);
|
---|
457 |
|
---|
458 | if (*(DWORD*)magic == IMAGE_NT_SIGNATURE)
|
---|
459 | return IMAGE_NT_SIGNATURE;
|
---|
460 |
|
---|
461 | if (*(WORD*)magic == IMAGE_OS2_SIGNATURE)
|
---|
462 | { IMAGE_OS2_HEADER ne_header;
|
---|
463 | LPBYTE pTypeInfo = (LPBYTE)-1;
|
---|
464 |
|
---|
465 | if (_lread(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
|
---|
466 | return 0;
|
---|
467 |
|
---|
468 | if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
|
---|
469 | return 0;
|
---|
470 |
|
---|
471 | size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
|
---|
472 |
|
---|
473 | //@@@PH no NE support
|
---|
474 | #if 0
|
---|
475 | if( size > sizeof(NE_TYPEINFO) )
|
---|
476 | { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
|
---|
477 | if( pTypeInfo )
|
---|
478 | { _llseek(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
|
---|
479 | if( _lread( hFile, (char*)pTypeInfo, size) != size )
|
---|
480 | { HeapFree( GetProcessHeap(), 0, pTypeInfo);
|
---|
481 | pTypeInfo = NULL;
|
---|
482 | }
|
---|
483 | }
|
---|
484 | }
|
---|
485 | #endif
|
---|
486 |
|
---|
487 | *retptr = pTypeInfo;
|
---|
488 | return IMAGE_OS2_SIGNATURE;
|
---|
489 | }
|
---|
490 | return 0; /* failed */
|
---|
491 | }
|
---|
492 |
|
---|
493 |
|
---|
494 | /*************************************************************************
|
---|
495 | * ExtractAssociatedIcon [SHELL.36]
|
---|
496 | *
|
---|
497 | * Return icon for given file (either from file itself or from associated
|
---|
498 | * executable) and patch parameters if needed.
|
---|
499 | */
|
---|
500 | ODINFUNCTION3(HICON, ExtractAssociatedIconA,
|
---|
501 | HINSTANCE, hInst,
|
---|
502 | LPSTR, lpIconPath,
|
---|
503 | LPWORD, lpiIcon)
|
---|
504 | {
|
---|
505 | HICON hIcon;
|
---|
506 |
|
---|
507 | hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
|
---|
508 |
|
---|
509 | if( hIcon < 2 )
|
---|
510 | { if( hIcon == 1 ) /* no icons found in given file */
|
---|
511 | { char tempPath[0x104];
|
---|
512 | UINT16 uRet = FindExecutableA(lpIconPath,NULL,tempPath);
|
---|
513 |
|
---|
514 | if( uRet > 32 && tempPath[0] )
|
---|
515 | { strcpy(lpIconPath,tempPath);
|
---|
516 | hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
|
---|
517 | if( hIcon > 2 )
|
---|
518 | return hIcon;
|
---|
519 | }
|
---|
520 | else hIcon = 0;
|
---|
521 | }
|
---|
522 |
|
---|
523 | if( hIcon == 1 )
|
---|
524 | *lpiIcon = 2; /* MSDOS icon - we found .exe but no icons in it */
|
---|
525 | else
|
---|
526 | *lpiIcon = 6; /* generic icon - found nothing */
|
---|
527 |
|
---|
528 | GetModuleFileNameA(hInst, lpIconPath, 0x80);
|
---|
529 | hIcon = LoadIconA( hInst, (LPCSTR)*lpiIcon);
|
---|
530 | }
|
---|
531 | return hIcon;
|
---|
532 | }
|
---|
533 |
|
---|