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

Last change on this file since 4032 was 4032, checked in by phaller, 25 years ago

Synchronized shell32 with wine

File size: 37.5 KB
Line 
1/* $Id: shellord.cpp,v 1.10 2000-08-18 02:01:22 phaller 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 * StrRetToStrN [SHELL32.96]
731 *
732 * converts a STRRET to a normal string
733 *
734 * NOTES
735 * the pidl is for STRRET OFFSET
736 */
737HRESULT WINAPI StrRetToBufA (LPSTRRET src, LPITEMIDLIST pidl, LPSTR dest, DWORD len)
738{
739 return StrRetToStrNA(dest, len, src, pidl);
740}
741
742HRESULT WINAPI StrRetToBufW (LPSTRRET src, LPITEMIDLIST pidl, LPWSTR dest, DWORD len)
743{
744 return StrRetToStrNW(dest, len, src, pidl);
745}
746
747
748/*************************************************************************
749 * StrChrA [NT 4.0:SHELL32.651]
750 *
751 */
752LPSTR WINAPI StrChrA (LPSTR str, CHAR x )
753{ LPSTR ptr=str;
754
755 do
756 { if (*ptr==x)
757 { return ptr;
758 }
759 ptr++;
760 } while (*ptr);
761 return NULL;
762}
763
764/*************************************************************************
765 * StrChrW [NT 4.0:SHELL32.651]
766 *
767 */
768LPWSTR WINAPI StrChrW (LPWSTR str, WCHAR x )
769{ LPWSTR ptr=str;
770
771 TRACE("%s 0x%04x\n",debugstr_w(str),x);
772 do
773 { if (*ptr==x)
774 { return ptr;
775 }
776 ptr++;
777 } while (*ptr);
778 return NULL;
779}
780
781/*************************************************************************
782 * StrCmpNIW [NT 4.0:SHELL32.*]
783 *
784 */
785INT WINAPI StrCmpNIW ( LPWSTR wstr1, LPWSTR wstr2, INT len)
786{ FIXME("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
787 return 0;
788}
789
790/*************************************************************************
791 * StrCmpNIA [NT 4.0:SHELL32.*]
792 *
793 */
794INT WINAPI StrCmpNIA ( LPSTR wstr1, LPSTR wstr2, INT len)
795{ FIXME("%s %s %i stub\n", wstr1,wstr2,len);
796 return 0;
797}
798
799/*************************************************************************
800 * SHAllocShared [SHELL32.520]
801 *
802 * NOTES
803 * parameter1 is return value from HeapAlloc
804 * parameter2 is equal to the size allocated with HeapAlloc
805 * parameter3 is return value from GetCurrentProcessId
806 *
807 * the return value is posted as lParam with 0x402 (WM_USER+2) to somewhere
808 * WM_USER+2 could be the undocumented CWM_SETPATH
809 * the allocated memory contains a pidl
810 */
811HGLOBAL WINAPI SHAllocShared(LPVOID psrc, DWORD size, DWORD procID)
812{ HGLOBAL hmem;
813 LPVOID pmem;
814
815 TRACE("ptr=%p size=0x%04lx procID=0x%04lx\n",psrc,size,procID);
816 hmem = GlobalAlloc(GMEM_FIXED, size);
817 if (!hmem)
818 return 0;
819
820 pmem = GlobalLock (hmem);
821
822 if (! pmem)
823 return 0;
824
825 memcpy (pmem, psrc, size);
826 GlobalUnlock(hmem);
827 return hmem;
828}
829/*************************************************************************
830 * SHLockShared [SHELL32.521]
831 *
832 * NOTES
833 * parameter1 is return value from SHAllocShared
834 * parameter2 is return value from GetCurrentProcessId
835 * the receiver of (WM_USER+2) trys to lock the HANDLE (?)
836 * the returnvalue seems to be a memoryadress
837 */
838LPVOID WINAPI SHLockShared(HANDLE hmem, DWORD procID)
839{ TRACE("handle=0x%04x procID=0x%04lx\n",hmem,procID);
840 return GlobalLock(hmem);
841}
842/*************************************************************************
843 * SHUnlockShared [SHELL32.522]
844 *
845 * NOTES
846 * parameter1 is return value from SHLockShared
847 */
848ODINFUNCTION1(BOOL, SHUnlockShared,
849 LPVOID, pv)
850{
851 TRACE("handle=0x%08x\n",pv);
852 //@@@PH rather VirtualUnlock ?
853 return GlobalUnlock((HANDLE)pv);
854}
855/*************************************************************************
856 * SHFreeShared [SHELL32.523]
857 *
858 * NOTES
859 * parameter1 is return value from SHAllocShared
860 * parameter2 is return value from GetCurrentProcessId
861 */
862HANDLE WINAPI SHFreeShared(HANDLE hmem, DWORD procID)
863{ TRACE("handle=0x%04x 0x%04lx\n",hmem,procID);
864 return GlobalFree(hmem);
865}
866
867/*************************************************************************
868 * SetAppStartingCursor [SHELL32.99]
869 *
870 */
871HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
872{ FIXME("hwnd=0x%04x 0x%04lx stub\n",u,v );
873 return 0;
874}
875/*************************************************************************
876 * SHLoadOLE [SHELL32.151]
877 *
878 */
879HRESULT WINAPI SHLoadOLE(DWORD u)
880{ FIXME("0x%04lx stub\n",u);
881 return S_OK;
882}
883/*************************************************************************
884 * DriveType [SHELL32.64]
885 *
886 */
887HRESULT WINAPI DriveType(DWORD u)
888{ FIXME("0x%04lx stub\n",u);
889 return 0;
890}
891/*************************************************************************
892 * SHAbortInvokeCommand [SHELL32.198]
893 *
894 */
895HRESULT WINAPI SHAbortInvokeCommand(void)
896{ FIXME("stub\n");
897 return 1;
898}
899/*************************************************************************
900 * SHOutOfMemoryMessageBox [SHELL32.126]
901 *
902 */
903ODINFUNCTION3(int, SHOutOfMemoryMessageBox,
904 HWND, hwndOwner,
905 LPCSTR, lpCaption,
906 UINT, uType)
907{
908 dprintf(("SHELL32: SHOutOfMemoryMessageBox not implemented."));
909 return 0;
910}
911/*************************************************************************
912 * SHFlushClipboard [SHELL32.121]
913 *
914 */
915HRESULT WINAPI SHFlushClipboard(void)
916{ FIXME("stub\n");
917 return 1;
918}
919/*************************************************************************
920 * StrRChrA [SHELL32.346]
921 *
922 */
923LPSTR WINAPI StrRChrA(LPCSTR lpStart, LPCSTR lpEnd, DWORD wMatch)
924{
925 if (!lpStart)
926 return NULL;
927
928 /* if the end not given, search*/
929 if (!lpEnd)
930 { lpEnd=lpStart;
931 while (*lpEnd)
932 lpEnd++;
933 }
934
935 for (--lpEnd;lpStart <= lpEnd; lpEnd--)
936 if (*lpEnd==(char)wMatch)
937 return (LPSTR)lpEnd;
938
939 return NULL;
940}
941/*************************************************************************
942 * StrRChrW [SHELL32.320]
943 *
944 */
945LPWSTR WINAPI StrRChrW(LPWSTR lpStart, LPWSTR lpEnd, DWORD wMatch)
946{ LPWSTR wptr=NULL;
947 TRACE("%s %s 0x%04x\n",debugstr_w(lpStart),debugstr_w(lpEnd), (WCHAR)wMatch );
948
949 /* if the end not given, search*/
950 if (!lpEnd)
951 { lpEnd=lpStart;
952 while (*lpEnd)
953 lpEnd++;
954 }
955
956 do
957 { if (*lpStart==(WCHAR)wMatch)
958 wptr = lpStart;
959 lpStart++;
960 } while ( lpStart<=lpEnd );
961 return wptr;
962}
963/*************************************************************************
964* StrFormatByteSize [SHLWAPI]
965*/
966LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
967{ char buf[64];
968 TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
969 if ( dw<1024L )
970 { sprintf (buf,"%3.0f bytes", (FLOAT)dw);
971 }
972 else if ( dw<1048576L)
973 { sprintf (buf,"%3.2f KB", (FLOAT)dw/1024);
974 }
975 else if ( dw < 1073741824L)
976 { sprintf (buf,"%3.2f MB", (FLOAT)dw/1048576L);
977 }
978 else
979 { sprintf (buf,"%3.2f GB", (FLOAT)dw/1073741824L);
980 }
981 lstrcpynA (pszBuf, buf, cchBuf);
982 return pszBuf;
983}
984LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
985{ char buf[64];
986 TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
987 if ( dw<1024L )
988 { sprintf (buf,"%3.0f bytes", (FLOAT)dw);
989 }
990 else if ( dw<1048576L)
991 { sprintf (buf,"%3.2f KB", (FLOAT)dw/1024);
992 }
993 else if ( dw < 1073741824L)
994 { sprintf (buf,"%3.2f MB", (FLOAT)dw/1048576L);
995 }
996 else
997 { sprintf (buf,"%3.2f GB", (FLOAT)dw/1073741824L);
998 }
999 lstrcpynAtoW (pszBuf, buf, cchBuf);
1000 return pszBuf;
1001}
1002/*************************************************************************
1003 * SHWaitForFileToOpen [SHELL32.97]
1004 *
1005 */
1006ODINFUNCTION3(BOOL, SHWaitForFileToOpen,
1007 LPCITEMIDLIST, pidl,
1008 DWORD, dwFlags,
1009 DWORD, dwTimeout)
1010{
1011 dprintf(("SHELL32: SHWaitForFileToOpen not implemented"));
1012 return 0;
1013}
1014/*************************************************************************
1015 * Control_FillCache_RunDLL [SHELL32.8]
1016 *
1017 */
1018HRESULT WINAPI Control_FillCache_RunDLL(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
1019{ FIXME("0x%04x 0x%04x 0x%04lx 0x%04lx stub\n",hWnd, hModule,w,x);
1020 return 0;
1021}
1022/*************************************************************************
1023 * RunDLL_CallEntry16 [SHELL32.122]
1024 * the name is propably wrong
1025 */
1026HRESULT WINAPI RunDLL_CallEntry16(DWORD v, DWORD w, DWORD x, DWORD y, DWORD z)
1027{ FIXME("0x%04lx 0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",v,w,x,y,z);
1028 return 0;
1029}
1030
1031/************************************************************************
1032 * shell32_654 [SHELL32.654]
1033 *
1034 * NOTES: first parameter seems to be a pointer (same as passed to WriteCabinetState)
1035 * second one could be a size (0x0c). The size is the same as the structure saved to
1036 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1037 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1038 */
1039HRESULT WINAPI shell32_654 (DWORD x, DWORD y)
1040{ FIXME("0x%08lx 0x%08lx stub\n",x,y);
1041 return 0;
1042}
1043
1044/************************************************************************
1045 * RLBuildListOfPaths [SHELL32.146]
1046 *
1047 * NOTES
1048 * builds a DPA
1049 */
1050DWORD WINAPI RLBuildListOfPaths (void)
1051{ FIXME("stub\n");
1052 return 0;
1053}
1054
1055/************************************************************************
1056 * SHValidateUNC [SHELL32.173]
1057 *
1058 */
1059HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1060{
1061 FIXME("0x%08lx 0x%08lx 0x%08lx stub\n",x,y,z);
1062 return 0;
1063}
1064
1065/************************************************************************
1066 * DoEnvironmentSubstW [SHELL32.53]
1067 *
1068 */
1069HRESULT WINAPI DoEnvironmentSubstA(LPSTR x, LPSTR y)
1070{
1071 FIXME("%p(%s) %p(%s) stub\n", x, x, y, y);
1072 return 0;
1073}
1074
1075HRESULT WINAPI DoEnvironmentSubstW(LPWSTR x, LPWSTR y)
1076{
1077 FIXME("%p(%s) %p(%s) stub\n", x, debugstr_w(x), y, debugstr_w(y));
1078 return 0;
1079}
1080
1081HRESULT WINAPI DoEnvironmentSubstAW(LPVOID x, LPVOID y)
1082{
1083 if (VERSION_OsIsUnicode())
1084 return DoEnvironmentSubstW((LPWSTR)x, (LPWSTR)y);
1085 return DoEnvironmentSubstA((LPSTR)x, (LPSTR)y);
1086}
1087
1088/*************************************************************************
1089 * shell32_243 [SHELL32.243]
1090 *
1091 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1092 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1093 *
1094 */
1095
1096BOOL WINAPI shell32_243(DWORD a, DWORD b)
1097{
1098 return FALSE;
1099}
1100
1101
1102/*****************************************************************************
1103 * Name : StrChrIA
1104 * Purpose : Searches a string for the first occurrence of a character that
1105 * matches the specified character. The comparison is not case sensitive.
1106 * Parameters: LPCSTR lpStart Address of the string to be searched.
1107 * TCHAR wMatch Character to be used for comparison.
1108 * Variables :
1109 * Result : Returns the address of the first occurrence of the character in
1110 * the string if successful, or NULL otherwise.
1111 * Remark : SHELL32.
1112 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1113 *
1114 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1115 *****************************************************************************/
1116
1117ODINFUNCTION2(LPSTR, StrChrIA,
1118 LPCSTR, lpStart,
1119 CHAR, wMatch)
1120{
1121 LPSTR lpRes;
1122
1123 wMatch = tolower(wMatch);
1124 lpRes = strchr(lpStart, wMatch); // lower case comparsion
1125 if (NULL == lpRes)
1126 {
1127 wMatch = toupper(wMatch);
1128 lpRes = strchr(lpStart, wMatch); // upper case comparsion
1129 }
1130
1131 return lpRes;
1132}
1133
1134
1135/*****************************************************************************
1136 * Name : StrChrIW
1137 * Purpose : Searches a string for the first occurrence of a character that
1138 * matches the specified character. The comparison is not case sensitive.
1139 * Parameters: LPCSTR lpStart Address of the string to be searched.
1140 * TCHAR wMatch Character to be used for comparison.
1141 * Variables :
1142 * Result : Returns the address of the first occurrence of the character in
1143 * the string if successful, or NULL otherwise.
1144 * Remark : SHELL32.
1145 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1146 *
1147 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1148 *****************************************************************************/
1149
1150ODINFUNCTION2(LPWSTR, StrChrIW,
1151 LPCWSTR, lpStart,
1152 WCHAR, wMatch)
1153{
1154 LPWSTR lpRes;
1155
1156 wMatch = towlower(wMatch);
1157 lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // lower case comparsion
1158 if (NULL == lpRes)
1159 {
1160 wMatch = towupper(wMatch);
1161 lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // upper case comparsion
1162 }
1163
1164 return lpRes;
1165}
1166
1167
1168/*****************************************************************************
1169 * Name : StrStrIA
1170 * Purpose : Finds the first occurrence of a substring within a string. The
1171 * comparison is not case sensitive.
1172 * Parameters: LPCSTR lpFirst
1173 * LPCSTR lpSrch
1174 * Variables :
1175 * Result : Returns the address of the first occurrence of the matching
1176 * substring if successful, or NULL otherwise.
1177 * Remark : SHELL32.
1178 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1179 *
1180 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1181 *****************************************************************************/
1182
1183ODINFUNCTION2(LPSTR, StrStrIA,
1184 LPCSTR, lpFirst,
1185 LPCSTR, lpSrch)
1186{
1187 char ch = lpSrch[0]; // look for 1st character
1188 LONG lLen = lstrlenA(lpSrch); // length of search string
1189 int iRes; // comparsion result
1190
1191 do
1192 {
1193 lpFirst = StrChrIA(lpFirst, // find first matching character
1194 ch);
1195 if (NULL == lpFirst) // not found
1196 return NULL;
1197
1198 iRes = StrCmpNIA((LPSTR)lpFirst, // compare search string
1199 (LPSTR)lpSrch,
1200 lLen);
1201
1202 if (0 == iRes) // Found!
1203 return (LPSTR)lpFirst;
1204
1205 lpFirst = CharNextA(lpFirst); // skip to next character
1206 }
1207 while (*lpFirst != 0); // safe termination
1208
1209 return NULL; // default result
1210}
1211
1212
1213
1214/*****************************************************************************
1215 * Name : StrStrIW
1216 * Purpose : Finds the first occurrence of a substring within a string. The
1217 * comparison is not case sensitive.
1218 * Parameters: LPCWSTR lpFirst
1219 * LPCWSTR lpSrch
1220 * Variables :
1221 * Result : Returns the address of the first occurrence of the matching
1222 * substring if successful, or NULL otherwise.
1223 * Remark : SHELL32.
1224 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
1225 *
1226 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
1227 *****************************************************************************/
1228
1229ODINFUNCTION2(LPWSTR, StrStrIW,
1230 LPCWSTR, lpFirst,
1231 LPCWSTR, lpSrch)
1232{
1233 WCHAR ch = lpSrch[0]; // look for 1st character
1234 LONG lLen = lstrlenW(lpSrch); // length of search string
1235 int iRes; // comparsion result
1236
1237 do
1238 {
1239 lpFirst = StrChrIW(lpFirst, // find first matching character
1240 ch);
1241 if (NULL == lpFirst) // not found
1242 return NULL;
1243
1244 iRes = StrCmpNIW((LPWSTR)lpFirst, // compare search string
1245 (LPWSTR)lpSrch,
1246 lLen);
1247
1248 if (0 == iRes) // Found!
1249 return (LPWSTR)lpFirst;
1250
1251 lpFirst = CharNextW(lpFirst); // skip to next character
1252 }
1253 while (*lpFirst != 0); // safe termination
1254
1255 return NULL; // default result
1256}
1257
1258
Note: See TracBrowser for help on using the repository browser.