source: trunk/src/shell32/shellord.cpp@ 4102

Last change on this file since 4102 was 4102, checked in by sandervl, 25 years ago

open/save dialog fix

File size: 37.0 KB
Line 
1/* $Id: shellord.cpp,v 1.11 2000-08-27 14:08:18 sandervl Exp $ */
2/*
3 * The parameters of many functions changes between different OS versions
4 * (NT uses Unicode strings, 95 uses ASCII strings)
5 *
6 * Copyright 1997 Marcus Meissner
7 * 1998 Jürgen Schmied
8 *
9 * Corel WINE 20000324 level
10 */
11
12
13/*****************************************************************************
14 * Includes *
15 *****************************************************************************/
16
17#include <string.h>
18#include <odin.h>
19#include <odinwrap.h>
20#include <os2sel.h>
21
22#define ICOM_CINTERFACE 1
23#define CINTERFACE 1
24
25#include "winerror.h"
26#include "winreg.h"
27#include "debugtools.h"
28#include "winnls.h"
29#include "winversion.h"
30#include "heap.h"
31
32#include "shellapi.h"
33#include "shlobj.h"
34#include "shell32_main.h"
35#include "wine/undocshell.h"
36#include "shpolicy.h"
37
38#include <heapstring.h>
39#include <misc.h>
40#include <ctype.h>
41#include <wctype.h>
42#include <wcstr.h>
43
44
45/*****************************************************************************
46 * Local Variables *
47 *****************************************************************************/
48
49ODINDEBUGCHANNEL(shell32-shellord)
50
51
52/*************************************************************************
53 * ParseField [SHELL32.58]
54 *
55 */
56DWORD WINAPI ParseFieldA(LPCSTR src, DWORD field, LPSTR dst, DWORD len)
57{ WARN("('%s',0x%08lx,%p,%ld) semi-stub.\n",src,field,dst,len);
58
59 if (!src || !src[0] || !dst || !len)
60 return 0;
61
62 if (field >1)
63 { field--;
64 while (field)
65 { if (*src==0x0) return FALSE;
66 if (*src==',') field--;
67 src++;
68 }
69 }
70
71 while (*src!=0x00 && *src!=',' && len>0)
72 { *dst=*src; dst++, src++; len--;
73 }
74 *dst=0x0;
75
76 return TRUE;
77}
78
79
80/*************************************************************************
81 * GetFileNameFromBrowse [SHELL32.63]
82 *
83 */
84ODINFUNCTION7(BOOL, GetFileNameFromBrowse,
85 HWND, hwndOwner,
86 LPSTR, lpstrFile,
87 DWORD, nMaxFile,
88 LPCSTR, lpstrInitialDir,
89 LPCSTR, lpstrDefExt,
90 LPCSTR, lpstrFIlter,
91 LPCSTR, lpstrTitle)
92{
93 dprintf(("SHELL32: GetFileNameFromBrowse not implemented"));
94
95 /* puts up a Open Dialog and requests input into targetbuf */
96 /* OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|OFN_unknown */
97 lstrcpynA(lpstrFile,
98 "x:\\dummy.exe",
99 nMaxFile);
100 return 1;
101}
102
103/*************************************************************************
104 * SHGetSettings [SHELL32.68]
105 *
106 * NOTES
107 * the registry path are for win98 (tested)
108 * and possibly are the same in nt40
109 */
110void WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask, DWORD dwx)
111{
112 HKEY hKey;
113 DWORD dwData;
114 DWORD dwDataSize = sizeof (DWORD);
115
116 TRACE("(%p 0x%08lx 0x%08lx)\n",lpsfs,dwMask, dwx);
117
118 if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
119 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
120 return;
121
122 if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
123 lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1);
124
125 if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
126 lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1);
127
128 if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
129 lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1);
130
131 if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
132 lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1);
133
134 if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
135 lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1);
136
137 if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
138 lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1);
139
140 if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
141 { if (dwData == 0)
142 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
143 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
144 }
145 else if (dwData == 1)
146 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1;
147 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
148 }
149 else if (dwData == 2)
150 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
151 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1;
152 }
153 }
154 RegCloseKey (hKey);
155
156 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
157}
158
159/*************************************************************************
160 * SHShellFolderView_Message [SHELL32.73]
161 *
162 * PARAMETERS
163 * hwndCabinet defines the explorer cabinet window that contains the
164 * shellview you need to communicate with
165 * uMsg identifying the SFVM enum to perform
166 * lParam
167 *
168 * NOTES
169 * Message SFVM_REARRANGE = 1
170 * This message gets sent when a column gets clicked to instruct the
171 * shell view to re-sort the item list. lParam identifies the column
172 * that was clicked.
173 */
174ODINFUNCTION3(int, SHShellFolderView_Message,
175 HWND, hwndCabinet,
176 DWORD, dwMessage,
177 DWORD, dwParam)
178{
179 dprintf(("SHELL32: SHShellFolderView_Message not implemented"));
180 return 0;
181}
182
183
184/*************************************************************************
185 * RegisterShellHook [SHELL32.181]
186 *
187 * PARAMS
188 * hwnd [I] window handle
189 * y [I] flag ????
190 *
191 * NOTES
192 * exported by ordinal
193 */
194ODINFUNCTION2(BOOL, RegisterShellHook,
195 HWND, hWnd,
196 DWORD, dwType)
197{
198 dprintf(("SHELL32: RegisterShellHook not implemented"));
199 return FALSE;
200}
201/*************************************************************************
202 * ShellMessageBoxW [SHELL32.182]
203 *
204 * Format and output errormessage.
205 *
206 * idText resource ID of title or LPSTR
207 * idTitle resource ID of title or LPSTR
208 *
209 * NOTES
210 * exported by ordinal
211 */
212INT __cdecl
213ShellMessageBoxW(HMODULE hmod,HWND hwnd,DWORD idText,DWORD idTitle,DWORD uType,LPCVOID arglist)
214{ WCHAR szText[100],szTitle[100],szTemp[256];
215 LPWSTR pszText = &szText[0], pszTitle = &szTitle[0];
216 LPVOID args = &arglist;
217
218 TRACE("(%08lx,%08lx,%08lx,%08lx,%08lx,%p)\n",(DWORD)hmod,(DWORD)hwnd,idText,idTitle,uType,arglist);
219
220 if (!HIWORD (idTitle))
221 LoadStringW(hmod,idTitle,pszTitle,100);
222 else
223 pszTitle = (LPWSTR)idTitle;
224
225 if (! HIWORD (idText))
226 LoadStringW(hmod,idText,pszText,100);
227 else
228 pszText = (LPWSTR)idText;
229
230 FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY,
231 szText,
232 0,
233 0,
234 szTemp,
235 256,
236 (LPDWORD)args);
237 return MessageBoxW(hwnd,szTemp,szTitle,uType);
238}
239
240/*************************************************************************
241 * ShellMessageBoxA [SHELL32.183]
242 */
243INT __cdecl
244ShellMessageBoxA(HMODULE hmod,HWND hwnd,DWORD idText,DWORD idTitle,DWORD uType,LPCVOID arglist)
245{ char szText[100],szTitle[100],szTemp[256];
246 LPSTR pszText = &szText[0], pszTitle = &szTitle[0];
247 LPVOID args = &arglist;
248
249 TRACE("(%08lx,%08lx,%08lx,%08lx,%08lx,%p)\n", (DWORD)hmod,(DWORD)hwnd,idText,idTitle,uType,arglist);
250
251 if (!HIWORD (idTitle))
252 LoadStringA(hmod,idTitle,pszTitle,100);
253 else
254 pszTitle = (LPSTR)idTitle;
255
256 if (! HIWORD (idText))
257 LoadStringA(hmod,idText,pszText,100);
258 else
259 pszText = (LPSTR)idText;
260
261 FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY ,pszText,0,0,szTemp,256,(LPDWORD)args);
262 return MessageBoxA(hwnd,szTemp,pszTitle,uType);
263}
264
265
266/*************************************************************************
267 * SHFree [SHELL32.195]
268 *
269 * NOTES
270 * free_ptr() - frees memory using IMalloc
271 * exported by ordinal
272 */
273#define MEM_DEBUG 0
274void WINAPI SHFree(LPVOID x)
275{
276#if MEM_DEBUG
277 WORD len = *(LPWORD)(x-2);
278
279 if ( *(LPWORD)(x+len) != 0x7384)
280 ERR("MAGIC2!\n");
281
282 if ( (*(LPWORD)(x-4)) != 0x8271)
283 ERR("MAGIC1!\n");
284 else
285 memset(x-4, 0xde, len+6);
286
287 TRACE("%p len=%u\n",x, len);
288
289 x -= 4;
290#else
291 TRACE("%p\n",x);
292#endif
293
294 HeapFree(GetProcessHeap(), 0, x);
295}
296
297/*************************************************************************
298 * SHAlloc [SHELL32.196]
299 *
300 * NOTES
301 * void *task_alloc(DWORD len), uses SHMalloc allocator
302 * exported by ordinal
303 */
304LPVOID WINAPI SHAlloc(DWORD len)
305{
306 LPBYTE ret;
307
308#if MEM_DEBUG
309 ret = (LPBYTE) HeapAlloc(GetProcessHeap(),0,len+6);
310#else
311 ret = (LPBYTE) HeapAlloc(GetProcessHeap(),0,len);
312#endif
313
314#if MEM_DEBUG
315 *(LPWORD)(ret) = 0x8271;
316 *(LPWORD)(ret+2) = (WORD)len;
317 *(LPWORD)(ret+4+len) = 0x7384;
318 ret += 4;
319 memset(ret, 0xdf, len);
320#endif
321 TRACE("%lu bytes at %p\n",len, ret);
322 return (LPVOID)ret;
323}
324
325/*************************************************************************
326 * SHRegisterDragDrop [SHELL32.86]
327 *
328 * NOTES
329 * exported by ordinal
330 */
331ODINFUNCTION2(HRESULT, SHRegisterDragDrop,
332 HWND, hWnd,
333 LPDROPTARGET, lpDropTarget)
334{
335 dprintf(("SHELL32: SHRegisterDragDrop not correctly implemented"));
336 return RegisterDragDrop(hWnd, lpDropTarget);
337}
338
339/*************************************************************************
340 * SHRevokeDragDrop [SHELL32.87]
341 *
342 * NOTES
343 * exported by ordinal
344 */
345ODINFUNCTION1(HRESULT, SHRevokeDragDrop,
346 HWND, hWnd)
347{
348 dprintf(("SHELL32: SHRevokeDragDrop not implemented"));
349 return 0;
350}
351
352/*************************************************************************
353 * SHDoDragDrop [SHELL32.88]
354 *
355 * NOTES
356 * exported by ordinal
357 */
358ODINFUNCTION5(HRESULT, SHDoDragDrop,
359 HWND, hWnd,
360 LPDATAOBJECT, lpDataObject,
361 LPDROPSOURCE, lpDropSource,
362 DWORD, dwOKEffect,
363 LPDWORD, pdwEffect)
364{
365 dprintf(("SHELL32: SHDoDragDrop not implemented"));
366 return 0;
367}
368
369
370/*************************************************************************
371 * ArrangeWindows [SHELL32.184]
372 *
373 */
374ODINFUNCTION5(WORD, ArrangeWindows,
375 HWND, hwndParent,
376 DWORD, dwReserved,
377 LPCRECT, lpRect,
378 WORD, cKids,
379 CONST HWND*, lpKids)
380{
381 dprintf(("SHELL32: ArrangeWindows not implemented"));
382 return 0;
383}
384
385/*************************************************************************
386 * SignalFileOpen [SHELL32.103]
387 *
388 * NOTES
389 * exported by ordinal
390 */
391DWORD WINAPI
392SignalFileOpen (DWORD dwParam1)
393{
394 FIXME("(0x%08lx):stub.\n", dwParam1);
395
396 return 0;
397}
398
399/*************************************************************************
400 * SHAddToRecentDocs [SHELL32.234]
401 *
402 * PARAMETERS
403 * uFlags [IN] SHARD_PATH or SHARD_PIDL
404 * pv [IN] string or pidl, NULL clears the list
405 *
406 * NOTES
407 * exported by name
408 */
409DWORD WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
410{ if (SHARD_PIDL==uFlags)
411 { FIXME("(0x%08x,pidl=%p):stub.\n", uFlags,pv);
412 }
413 else
414 { FIXME("(0x%08x,%s):stub.\n", uFlags,(char*)pv);
415 }
416 return 0;
417}
418
419/*************************************************************************
420 * SHChangeNotify [SHELL32.239]
421 *
422 * NOTES
423 * exported by name
424 */
425DWORD WINAPI SHChangeNotify (
426 INT wEventId, /* [IN] flags that specifies the event*/
427 UINT uFlags, /* [IN] the meaning of dwItem[1|2]*/
428 LPCVOID dwItem1,
429 LPCVOID dwItem2)
430{ FIXME("(0x%08x,0x%08ux,%p,%p):stub.\n", wEventId,uFlags,dwItem1,dwItem2);
431 return 0;
432}
433/*************************************************************************
434 * SHCreateShellFolderViewEx [SHELL32.174]
435 *
436 * NOTES
437 * see IShellFolder::CreateViewObject
438 */
439ODINFUNCTION2(HRESULT, SHCreateShellFolderViewEx,
440 LPCSHELLFOLDERVIEWINFO, pshfvi,
441 LPSHELLVIEW*, ppshv)
442{
443 IShellView * psf;
444 HRESULT hRes;
445
446 psf = IShellView_Constructor(pshfvi->pshf);
447
448 if (!psf)
449 return E_OUTOFMEMORY;
450
451 IShellView_AddRef(psf);
452 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppshv);
453 IShellView_Release(psf);
454
455 return hRes;
456}
457/*************************************************************************
458 * SHWinHelp [SHELL32.127]
459 *
460 */
461HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
462{ FIXME("0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",v,w,x,z);
463 return 0;
464}
465/*************************************************************************
466 * SHRunControlPanel [SHELL32.161]
467 *
468 */
469HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
470{ FIXME("0x%08lx 0x%08lx stub\n",x,z);
471 return 0;
472}
473/*************************************************************************
474 * ShellExecuteEx [SHELL32.291]
475 *
476 */
477BOOL WINAPI ShellExecuteExAW (LPVOID sei)
478{ if (VERSION_OsIsUnicode())
479 return ShellExecuteExW ((LPSHELLEXECUTEINFOW)sei);
480 return ShellExecuteExA ((LPSHELLEXECUTEINFOA)sei);
481}
482/*************************************************************************
483 * ShellExecuteExA [SHELL32.292]
484 *
485 * placeholder in the commandline:
486 * %1 file
487 * %2 printer
488 * %3 driver
489 * %4 port
490 * %I adress of a global item ID (explorer switch /idlist)
491 * %L ??? path/url/current file ???
492 * %S ???
493 * %* all following parameters (see batfile)
494 */
495#include "process.h" /* we can get rid of it hopefully */
496#include "task.h"
497BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei)
498{ CHAR szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20];
499 LPSTR pos;
500 int gap, len;
501 STARTUPINFOA startup;
502 PROCESS_INFORMATION info;
503
504 WARN("mask=0x%08lx hwnd=0x%04x verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s incomplete\n",
505 sei->fMask, sei->hwnd, sei->lpVerb, sei->lpFile,
506 sei->lpParameters, sei->lpDirectory, sei->nShow,
507 (sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass : "not used");
508
509 ZeroMemory(szApplicationName,MAX_PATH);
510 if (sei->lpFile)
511 strcpy(szApplicationName, sei->lpFile);
512
513 ZeroMemory(szCommandline,MAX_PATH);
514 if (sei->lpParameters)
515 strcpy(szCommandline, sei->lpParameters);
516
517 if (sei->fMask & (SEE_MASK_CLASSKEY | SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
518 SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
519 SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE |
520 SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR ))
521 {
522 FIXME("flags ignored: 0x%08lx\n", sei->fMask);
523 }
524
525 /* launch a document by fileclass like 'Wordpad.Document.1' */
526 if (sei->fMask & SEE_MASK_CLASSNAME)
527 {
528 /* the commandline contains 'c:\Path\wordpad.exe "%1"' */
529 HCR_GetExecuteCommand(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, 256);
530 /* fixme: get the extension of lpFile, check if it fits to the lpClass */
531 TRACE("SEE_MASK_CLASSNAME->'%s'\n", szCommandline);
532 }
533
534 /* process the IDList */
535 if ( (sei->fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST) /*0x0c*/
536 {
537 SHGetPathFromIDListA ((LPCITEMIDLIST)sei->lpIDList,szApplicationName);
538 TRACE("-- idlist=%p (%s)\n", sei->lpIDList, szApplicationName);
539 }
540 else
541 {
542 if (sei->fMask & SEE_MASK_IDLIST )
543 {
544 pos = strstr(szCommandline, "%I");
545 if (pos)
546 {
547 LPVOID pv;
548 HGLOBAL hmem = SHAllocShared ( (LPITEMIDLIST)sei->lpIDList, ILGetSize((LPITEMIDLIST)sei->lpIDList), 0);
549 pv = SHLockShared(hmem,0);
550 sprintf(szPidl,":%p",pv );
551 SHUnlockShared(pv);
552
553 gap = strlen(szPidl);
554 len = strlen(pos)-2;
555 memmove(pos+gap,pos+2,len);
556 memcpy(pos,szPidl,gap);
557
558 }
559 }
560 }
561
562 TRACE("execute:'%s','%s'\n",szApplicationName, szCommandline);
563
564 strcat(szApplicationName, " ");
565 strcat(szApplicationName, szCommandline);
566
567 ZeroMemory(&startup,sizeof(STARTUPINFOA));
568 startup.cb = sizeof(STARTUPINFOA);
569
570 if (! CreateProcessA(NULL, szApplicationName,
571 NULL, NULL, FALSE, 0,
572 NULL, NULL, &startup, &info))
573 {
574 sei->hInstApp = GetLastError();
575 return FALSE;
576 }
577
578 sei->hInstApp = 33;
579
580 /* Give 30 seconds to the app to come up */
581 if ( WaitForInputIdle ( info.hProcess, 30000 ) == 0xFFFFFFFF )
582 ERR("WaitForInputIdle failed: Error %ld\n", GetLastError() );
583
584 if(sei->fMask & SEE_MASK_NOCLOSEPROCESS)
585 sei->hProcess = info.hProcess;
586 else
587 CloseHandle( info.hProcess );
588 CloseHandle( info.hThread );
589 return TRUE;
590}
591
592/*************************************************************************
593 * ShellExecuteExW [SHELL32.293]
594 *
595 */
596BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei)
597{ SHELLEXECUTEINFOA seiA;
598 DWORD ret;
599
600 TRACE("%p\n", sei);
601
602 memcpy(&seiA, sei, sizeof(SHELLEXECUTEINFOA));
603
604 if (sei->lpVerb)
605 seiA.lpVerb = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpVerb);
606
607 if (sei->lpFile)
608 seiA.lpFile = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpFile);
609
610 if (sei->lpParameters)
611 seiA.lpParameters = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpParameters);
612
613 if (sei->lpDirectory)
614 seiA.lpDirectory = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpDirectory);
615
616 if ((sei->fMask & SEE_MASK_CLASSNAME) && sei->lpClass)
617 seiA.lpClass = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpClass);
618 else
619 seiA.lpClass = NULL;
620
621 ret = ShellExecuteExA(&seiA);
622
623 if (seiA.lpVerb) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpVerb );
624 if (seiA.lpFile) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpFile );
625 if (seiA.lpParameters) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpParameters );
626 if (seiA.lpDirectory) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpDirectory );
627 if (seiA.lpClass) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpClass );
628
629 return ret;
630}
631
632static LPUNKNOWN SHELL32_IExplorerInterface=0;
633/*************************************************************************
634 * SHSetInstanceExplorer [SHELL32.176]
635 *
636 * NOTES
637 * Sets the interface
638 */
639HRESULT WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
640{ TRACE("%p\n", lpUnknown);
641 SHELL32_IExplorerInterface = lpUnknown;
642 return (HRESULT) lpUnknown;
643}
644/*************************************************************************
645 * SHGetInstanceExplorer [SHELL32.256]
646 *
647 * NOTES
648 * gets the interface pointer of the explorer and a reference
649 */
650HRESULT WINAPI SHGetInstanceExplorer (LPUNKNOWN * lpUnknown)
651{ TRACE("%p\n", lpUnknown);
652
653 *lpUnknown = SHELL32_IExplorerInterface;
654
655 if (!SHELL32_IExplorerInterface)
656 return E_FAIL;
657
658 IUnknown_AddRef(SHELL32_IExplorerInterface);
659 return NOERROR;
660}
661/*************************************************************************
662 * SHFreeUnusedLibraries [SHELL32.123]
663 *
664 * NOTES
665 * exported by name
666 */
667ODINPROCEDURE0(SHFreeUnusedLibraries)
668{
669 dprintf(("SHELL32: SHFreeUnusedLibraries not implemented"));
670}
671/*************************************************************************
672 * DAD_SetDragImage [SHELL32.136]
673 *
674 * NOTES
675 * exported by name
676 */
677ODINFUNCTION2(BOOL, DAD_SetDragImage,
678 HIMAGELIST, himlTrack,
679 LPPOINT, lppt)
680{
681 dprintf(("SHELL32: DAD_SetDragImage not implemented"));
682 return 0;
683}
684/*************************************************************************
685 * DAD_ShowDragImage [SHELL32.137]
686 *
687 * NOTES
688 * exported by name
689 */
690ODINFUNCTION1(BOOL, DAD_ShowDragImage,
691 BOOL, bShow)
692{
693 dprintf(("SHELL32: DAD_ShowDragImage not implemented"));
694 return 0;
695}
696
697/*************************************************************************
698 * ReadCabinetState [NT 4.0:SHELL32.651]
699 *
700 */
701HRESULT WINAPI ReadCabinetState(DWORD u, DWORD v)
702{ FIXME("0x%04lx 0x%04lx stub\n",u,v);
703 return 0;
704}
705/*************************************************************************
706 * WriteCabinetState [NT 4.0:SHELL32.652]
707 *
708 */
709HRESULT WINAPI WriteCabinetState(DWORD u)
710{ FIXME("0x%04lx stub\n",u);
711 return 0;
712}
713/*************************************************************************
714 * FileIconInit [SHELL32.660]
715 *
716 */
717BOOL WINAPI FileIconInit(BOOL bFullInit)
718{ FIXME("(%s)\n", bFullInit ? "true" : "false");
719 return 0;
720}
721/*************************************************************************
722 * IsUserAdmin [NT 4.0:SHELL32.680]
723 *
724 */
725HRESULT WINAPI IsUserAdmin(void)
726{ FIXME("stub\n");
727 return TRUE;
728}
729
730
731/*************************************************************************
732 * StrChrA [NT 4.0:SHELL32.651]
733 *
734 */
735LPSTR WINAPI StrChrA (LPSTR str, CHAR x )
736{ LPSTR ptr=str;
737
738 do
739 { if (*ptr==x)
740 { return ptr;
741 }
742 ptr++;
743 } while (*ptr);
744 return NULL;
745}
746
747/*************************************************************************
748 * StrChrW [NT 4.0:SHELL32.651]
749 *
750 */
751LPWSTR WINAPI StrChrW (LPWSTR str, WCHAR x )
752{ LPWSTR ptr=str;
753
754 TRACE("%s 0x%04x\n",debugstr_w(str),x);
755 do
756 { if (*ptr==x)
757 { return ptr;
758 }
759 ptr++;
760 } while (*ptr);
761 return NULL;
762}
763
764/*************************************************************************
765 * StrCmpNIW [NT 4.0:SHELL32.*]
766 *
767 */
768INT WINAPI StrCmpNIW ( LPWSTR wstr1, LPWSTR wstr2, INT len)
769{ FIXME("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
770 return 0;
771}
772
773/*************************************************************************
774 * StrCmpNIA [NT 4.0:SHELL32.*]
775 *
776 */
777INT WINAPI StrCmpNIA ( LPSTR wstr1, LPSTR wstr2, INT len)
778{ FIXME("%s %s %i stub\n", wstr1,wstr2,len);
779 return 0;
780}
781
782/*************************************************************************
783 * SHAllocShared [SHELL32.520]
784 *
785 * NOTES
786 * parameter1 is return value from HeapAlloc
787 * parameter2 is equal to the size allocated with HeapAlloc
788 * parameter3 is return value from GetCurrentProcessId
789 *
790 * the return value is posted as lParam with 0x402 (WM_USER+2) to somewhere
791 * WM_USER+2 could be the undocumented CWM_SETPATH
792 * the allocated memory contains a pidl
793 */
794HGLOBAL WINAPI SHAllocShared(LPVOID psrc, DWORD size, DWORD procID)
795{ HGLOBAL hmem;
796 LPVOID pmem;
797
798 TRACE("ptr=%p size=0x%04lx procID=0x%04lx\n",psrc,size,procID);
799 hmem = GlobalAlloc(GMEM_FIXED, size);
800 if (!hmem)
801 return 0;
802
803 pmem = GlobalLock (hmem);
804
805 if (! pmem)
806 return 0;
807
808 memcpy (pmem, psrc, size);
809 GlobalUnlock(hmem);
810 return hmem;
811}
812/*************************************************************************
813 * SHLockShared [SHELL32.521]
814 *
815 * NOTES
816 * parameter1 is return value from SHAllocShared
817 * parameter2 is return value from GetCurrentProcessId
818 * the receiver of (WM_USER+2) trys to lock the HANDLE (?)
819 * the returnvalue seems to be a memoryadress
820 */
821LPVOID WINAPI SHLockShared(HANDLE hmem, DWORD procID)
822{ TRACE("handle=0x%04x procID=0x%04lx\n",hmem,procID);
823 return GlobalLock(hmem);
824}
825/*************************************************************************
826 * SHUnlockShared [SHELL32.522]
827 *
828 * NOTES
829 * parameter1 is return value from SHLockShared
830 */
831ODINFUNCTION1(BOOL, SHUnlockShared,
832 LPVOID, pv)
833{
834 TRACE("handle=0x%08x\n",pv);
835 //@@@PH rather VirtualUnlock ?
836 return GlobalUnlock((HANDLE)pv);
837}
838/*************************************************************************
839 * SHFreeShared [SHELL32.523]
840 *
841 * NOTES
842 * parameter1 is return value from SHAllocShared
843 * parameter2 is return value from GetCurrentProcessId
844 */
845HANDLE WINAPI SHFreeShared(HANDLE hmem, DWORD procID)
846{ TRACE("handle=0x%04x 0x%04lx\n",hmem,procID);
847 return GlobalFree(hmem);
848}
849
850/*************************************************************************
851 * SetAppStartingCursor [SHELL32.99]
852 *
853 */
854HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
855{ FIXME("hwnd=0x%04x 0x%04lx stub\n",u,v );
856 return 0;
857}
858/*************************************************************************
859 * SHLoadOLE [SHELL32.151]
860 *
861 */
862HRESULT WINAPI SHLoadOLE(DWORD u)
863{ FIXME("0x%04lx stub\n",u);
864 return S_OK;
865}
866/*************************************************************************
867 * DriveType [SHELL32.64]
868 *
869 */
870HRESULT WINAPI DriveType(DWORD u)
871{ FIXME("0x%04lx stub\n",u);
872 return 0;
873}
874/*************************************************************************
875 * SHAbortInvokeCommand [SHELL32.198]
876 *
877 */
878HRESULT WINAPI SHAbortInvokeCommand(void)
879{ FIXME("stub\n");
880 return 1;
881}
882/*************************************************************************
883 * SHOutOfMemoryMessageBox [SHELL32.126]
884 *
885 */
886ODINFUNCTION3(int, SHOutOfMemoryMessageBox,
887 HWND, hwndOwner,
888 LPCSTR, lpCaption,
889 UINT, uType)
890{
891 dprintf(("SHELL32: SHOutOfMemoryMessageBox not implemented."));
892 return 0;
893}
894/*************************************************************************
895 * SHFlushClipboard [SHELL32.121]
896 *
897 */
898HRESULT WINAPI SHFlushClipboard(void)
899{ FIXME("stub\n");
900 return 1;
901}
902/*************************************************************************
903 * StrRChrA [SHELL32.346]
904 *
905 */
906LPSTR WINAPI StrRChrA(LPCSTR lpStart, LPCSTR lpEnd, DWORD wMatch)
907{
908 if (!lpStart)
909 return NULL;
910
911 /* if the end not given, search*/
912 if (!lpEnd)
913 { lpEnd=lpStart;
914 while (*lpEnd)
915 lpEnd++;
916 }
917
918 for (--lpEnd;lpStart <= lpEnd; lpEnd--)
919 if (*lpEnd==(char)wMatch)
920 return (LPSTR)lpEnd;
921
922 return NULL;
923}
924/*************************************************************************
925 * StrRChrW [SHELL32.320]
926 *
927 */
928LPWSTR WINAPI StrRChrW(LPWSTR lpStart, LPWSTR lpEnd, DWORD wMatch)
929{ LPWSTR wptr=NULL;
930 TRACE("%s %s 0x%04x\n",debugstr_w(lpStart),debugstr_w(lpEnd), (WCHAR)wMatch );
931
932 /* if the end not given, search*/
933 if (!lpEnd)
934 { lpEnd=lpStart;
935 while (*lpEnd)
936 lpEnd++;
937 }
938
939 do
940 { if (*lpStart==(WCHAR)wMatch)
941 wptr = lpStart;
942 lpStart++;
943 } while ( lpStart<=lpEnd );
944 return wptr;
945}
946/*************************************************************************
947* StrFormatByteSize [SHLWAPI]
948*/
949LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
950{ char buf[64];
951 TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
952 if ( dw<1024L )
953 { sprintf (buf,"%3.0f bytes", (FLOAT)dw);
954 }
955 else if ( dw<1048576L)
956 { sprintf (buf,"%3.2f KB", (FLOAT)dw/1024);
957 }
958 else if ( dw < 1073741824L)
959 { sprintf (buf,"%3.2f MB", (FLOAT)dw/1048576L);
960 }
961 else
962 { sprintf (buf,"%3.2f GB", (FLOAT)dw/1073741824L);
963 }
964 lstrcpynA (pszBuf, buf, cchBuf);
965 return pszBuf;
966}
967LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
968{ char buf[64];
969 TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
970 if ( dw<1024L )
971 { sprintf (buf,"%3.0f bytes", (FLOAT)dw);
972 }
973 else if ( dw<1048576L)
974 { sprintf (buf,"%3.2f KB", (FLOAT)dw/1024);
975 }
976 else if ( dw < 1073741824L)
977 { sprintf (buf,"%3.2f MB", (FLOAT)dw/1048576L);
978 }
979 else
980 { sprintf (buf,"%3.2f GB", (FLOAT)dw/1073741824L);
981 }
982 lstrcpynAtoW (pszBuf, buf, cchBuf);
983 return pszBuf;
984}
985/*************************************************************************
986 * SHWaitForFileToOpen [SHELL32.97]
987 *
988 */
989ODINFUNCTION3(BOOL, SHWaitForFileToOpen,
990 LPCITEMIDLIST, pidl,
991 DWORD, dwFlags,
992 DWORD, dwTimeout)
993{
994 dprintf(("SHELL32: SHWaitForFileToOpen not implemented"));
995 return 0;
996}
997/*************************************************************************
998 * Control_FillCache_RunDLL [SHELL32.8]
999 *
1000 */
1001HRESULT WINAPI Control_FillCache_RunDLL(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
1002{ FIXME("0x%04x 0x%04x 0x%04lx 0x%04lx stub\n",hWnd, hModule,w,x);
1003 return 0;
1004}
1005/*************************************************************************
1006 * RunDLL_CallEntry16 [SHELL32.122]
1007 * the name is propably wrong
1008 */
1009HRESULT WINAPI RunDLL_CallEntry16(DWORD v, DWORD w, DWORD x, DWORD y, DWORD z)
1010{ FIXME("0x%04lx 0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",v,w,x,y,z);
1011 return 0;
1012}
1013
1014/************************************************************************
1015 * shell32_654 [SHELL32.654]
1016 *
1017 * NOTES: first parameter seems to be a pointer (same as passed to WriteCabinetState)
1018 * second one could be a size (0x0c). The size is the same as the structure saved to
1019 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1020 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1021 */
1022HRESULT WINAPI shell32_654 (DWORD x, DWORD y)
1023{ FIXME("0x%08lx 0x%08lx stub\n",x,y);
1024 return 0;
1025}
1026
1027/************************************************************************
1028 * RLBuildListOfPaths [SHELL32.146]
1029 *
1030 * NOTES
1031 * builds a DPA
1032 */
1033DWORD WINAPI RLBuildListOfPaths (void)
1034{ FIXME("stub\n");
1035 return 0;
1036}
1037
1038/************************************************************************
1039 * SHValidateUNC [SHELL32.173]
1040 *
1041 */
1042HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1043{
1044 FIXME("0x%08lx 0x%08lx 0x%08lx stub\n",x,y,z);
1045 return 0;
1046}
1047
1048/************************************************************************
1049 * DoEnvironmentSubstW [SHELL32.53]
1050 *
1051 */
1052HRESULT WINAPI DoEnvironmentSubstA(LPSTR x, LPSTR y)
1053{
1054 FIXME("%p(%s) %p(%s) stub\n", x, x, y, y);
1055 return 0;
1056}
1057
1058HRESULT WINAPI DoEnvironmentSubstW(LPWSTR x, LPWSTR y)
1059{
1060 FIXME("%p(%s) %p(%s) stub\n", x, debugstr_w(x), y, debugstr_w(y));
1061 return 0;
1062}
1063
1064HRESULT WINAPI DoEnvironmentSubstAW(LPVOID x, LPVOID y)
1065{
1066 if (VERSION_OsIsUnicode())
1067 return DoEnvironmentSubstW((LPWSTR)x, (LPWSTR)y);
1068 return DoEnvironmentSubstA((LPSTR)x, (LPSTR)y);
1069}
1070
1071/*************************************************************************
1072 * shell32_243 [SHELL32.243]
1073 *
1074 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1075 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1076 *
1077 */
1078
1079BOOL WINAPI shell32_243(DWORD a, DWORD b)
1080{
1081 return FALSE;
1082}
1083
1084
1085/*****************************************************************************
1086 * Name : StrChrIA
1087 * Purpose : Searches a string for the first occurrence of a character that
1088 * matches the specified character. The comparison is not case sensitive.
1089 * Parameters: LPCSTR lpStart Address of the string to be searched.
1090 * TCHAR wMatch Character to be used for comparison.
1091 * Variables :
1092 * Result : Returns the address of the first occurrence of the character in
1093 * the string if successful, or NULL otherwise.
1094 * Remark : SHELL32.
1095 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1096 *
1097 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1098 *****************************************************************************/
1099
1100ODINFUNCTION2(LPSTR, StrChrIA,
1101 LPCSTR, lpStart,
1102 CHAR, wMatch)
1103{
1104 LPSTR lpRes;
1105
1106 wMatch = tolower(wMatch);
1107 lpRes = strchr(lpStart, wMatch); // lower case comparsion
1108 if (NULL == lpRes)
1109 {
1110 wMatch = toupper(wMatch);
1111 lpRes = strchr(lpStart, wMatch); // upper case comparsion
1112 }
1113
1114 return lpRes;
1115}
1116
1117
1118/*****************************************************************************
1119 * Name : StrChrIW
1120 * Purpose : Searches a string for the first occurrence of a character that
1121 * matches the specified character. The comparison is not case sensitive.
1122 * Parameters: LPCSTR lpStart Address of the string to be searched.
1123 * TCHAR wMatch Character to be used for comparison.
1124 * Variables :
1125 * Result : Returns the address of the first occurrence of the character in
1126 * the string if successful, or NULL otherwise.
1127 * Remark : SHELL32.
1128 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1129 *
1130 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1131 *****************************************************************************/
1132
1133ODINFUNCTION2(LPWSTR, StrChrIW,
1134 LPCWSTR, lpStart,
1135 WCHAR, wMatch)
1136{
1137 LPWSTR lpRes;
1138
1139 wMatch = towlower(wMatch);
1140 lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // lower case comparsion
1141 if (NULL == lpRes)
1142 {
1143 wMatch = towupper(wMatch);
1144 lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // upper case comparsion
1145 }
1146
1147 return lpRes;
1148}
1149
1150
1151/*****************************************************************************
1152 * Name : StrStrIA
1153 * Purpose : Finds the first occurrence of a substring within a string. The
1154 * comparison is not case sensitive.
1155 * Parameters: LPCSTR lpFirst
1156 * LPCSTR lpSrch
1157 * Variables :
1158 * Result : Returns the address of the first occurrence of the matching
1159 * substring if successful, or NULL otherwise.
1160 * Remark : SHELL32.
1161 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1162 *
1163 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1164 *****************************************************************************/
1165
1166ODINFUNCTION2(LPSTR, StrStrIA,
1167 LPCSTR, lpFirst,
1168 LPCSTR, lpSrch)
1169{
1170 char ch = lpSrch[0]; // look for 1st character
1171 LONG lLen = lstrlenA(lpSrch); // length of search string
1172 int iRes; // comparsion result
1173
1174 do
1175 {
1176 lpFirst = StrChrIA(lpFirst, // find first matching character
1177 ch);
1178 if (NULL == lpFirst) // not found
1179 return NULL;
1180
1181 iRes = StrCmpNIA((LPSTR)lpFirst, // compare search string
1182 (LPSTR)lpSrch,
1183 lLen);
1184
1185 if (0 == iRes) // Found!
1186 return (LPSTR)lpFirst;
1187
1188 lpFirst = CharNextA(lpFirst); // skip to next character
1189 }
1190 while (*lpFirst != 0); // safe termination
1191
1192 return NULL; // default result
1193}
1194
1195
1196
1197/*****************************************************************************
1198 * Name : StrStrIW
1199 * Purpose : Finds the first occurrence of a substring within a string. The
1200 * comparison is not case sensitive.
1201 * Parameters: LPCWSTR lpFirst
1202 * LPCWSTR lpSrch
1203 * Variables :
1204 * Result : Returns the address of the first occurrence of the matching
1205 * substring if successful, or NULL otherwise.
1206 * Remark : SHELL32.
1207 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1208 *
1209 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1210 *****************************************************************************/
1211
1212ODINFUNCTION2(LPWSTR, StrStrIW,
1213 LPCWSTR, lpFirst,
1214 LPCWSTR, lpSrch)
1215{
1216 WCHAR ch = lpSrch[0]; // look for 1st character
1217 LONG lLen = lstrlenW(lpSrch); // length of search string
1218 int iRes; // comparsion result
1219
1220 do
1221 {
1222 lpFirst = StrChrIW(lpFirst, // find first matching character
1223 ch);
1224 if (NULL == lpFirst) // not found
1225 return NULL;
1226
1227 iRes = StrCmpNIW((LPWSTR)lpFirst, // compare search string
1228 (LPWSTR)lpSrch,
1229 lLen);
1230
1231 if (0 == iRes) // Found!
1232 return (LPWSTR)lpFirst;
1233
1234 lpFirst = CharNextW(lpFirst); // skip to next character
1235 }
1236 while (*lpFirst != 0); // safe termination
1237
1238 return NULL; // default result
1239}
1240
1241
Note: See TracBrowser for help on using the repository browser.