2 * The parameters of many functions changes between different OS versions
3 * (NT uses Unicode strings, 95 uses ASCII strings)
5 * Copyright 1997 Marcus Meissner
12 #include "debugtools.h"
14 #include "winversion.h"
20 #include "shell32_main.h"
21 #include "wine/undocshell.h"
24 DEFAULT_DEBUG_CHANNEL(shell);
26 /*************************************************************************
27 * ParseFieldA [SHELL32.58]
29 * copys a field from a ',' delimited string
31 * first field is nField = 1
33 DWORD WINAPI ParseFieldA(LPCSTR src, DWORD nField, LPSTR dst, DWORD len)
35 WARN("('%s',0x%08lx,%p,%ld) semi-stub.\n",src,nField,dst,len);
37 if (!src || !src[0] || !dst || !len)
40 /* skip n fields delimited by ',' */
43 if (*src=='\0') return FALSE;
44 if (*(src++)==',') nField--;
47 /* copy part till the next ',' to dst */
48 while ( *src!='\0' && *src!=',' && (len--)>0 ) *(dst++)=*(src++);
50 /* finalize the string */
56 /*************************************************************************
57 * PickIconDlg [SHELL32.62]
60 DWORD WINAPI PickIconDlg(DWORD x,DWORD y,DWORD z,DWORD a)
61 { FIXME("(%08lx,%08lx,%08lx,%08lx):stub.\n",x,y,z,a);
65 /*************************************************************************
66 * GetFileNameFromBrowse [SHELL32.63]
69 DWORD WINAPI GetFileNameFromBrowse(HWND howner, LPSTR targetbuf, DWORD len, DWORD x, LPCSTR suffix, LPCSTR y, LPCSTR cmd)
70 { FIXME("(%04x,%p,%ld,%08lx,%s,%s,%s):stub.\n",
71 howner,targetbuf,len,x,suffix,y,cmd);
72 /* puts up a Open Dialog and requests input into targetbuf */
73 /* OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|OFN_unknown */
74 lstrcpyA(targetbuf,"x:\\dummy.exe");
78 /*************************************************************************
79 * SHGetSettings [SHELL32.68]
82 * the registry path are for win98 (tested)
83 * and possibly are the same in nt40
85 void WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask, DWORD dwx)
89 DWORD dwDataSize = sizeof (DWORD);
91 TRACE("(%p 0x%08lx 0x%08lx)\n",lpsfs,dwMask, dwx);
93 if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
94 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0))
97 if ( (SSF_SHOWEXTENSIONS & dwMask) && !RegQueryValueExA(hKey, "HideFileExt", 0, 0, (LPBYTE)&dwData, &dwDataSize))
98 lpsfs->fShowExtensions = ((dwData == 0) ? 0 : 1);
100 if ( (SSF_SHOWINFOTIP & dwMask) && !RegQueryValueExA(hKey, "ShowInfoTip", 0, 0, (LPBYTE)&dwData, &dwDataSize))
101 lpsfs->fShowInfoTip = ((dwData == 0) ? 0 : 1);
103 if ( (SSF_DONTPRETTYPATH & dwMask) && !RegQueryValueExA(hKey, "DontPrettyPath", 0, 0, (LPBYTE)&dwData, &dwDataSize))
104 lpsfs->fDontPrettyPath = ((dwData == 0) ? 0 : 1);
106 if ( (SSF_HIDEICONS & dwMask) && !RegQueryValueExA(hKey, "HideIcons", 0, 0, (LPBYTE)&dwData, &dwDataSize))
107 lpsfs->fHideIcons = ((dwData == 0) ? 0 : 1);
109 if ( (SSF_MAPNETDRVBUTTON & dwMask) && !RegQueryValueExA(hKey, "MapNetDrvBtn", 0, 0, (LPBYTE)&dwData, &dwDataSize))
110 lpsfs->fMapNetDrvBtn = ((dwData == 0) ? 0 : 1);
112 if ( (SSF_SHOWATTRIBCOL & dwMask) && !RegQueryValueExA(hKey, "ShowAttribCol", 0, 0, (LPBYTE)&dwData, &dwDataSize))
113 lpsfs->fShowAttribCol = ((dwData == 0) ? 0 : 1);
115 if (((SSF_SHOWALLOBJECTS | SSF_SHOWSYSFILES) & dwMask) && !RegQueryValueExA(hKey, "Hidden", 0, 0, (LPBYTE)&dwData, &dwDataSize))
117 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
118 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
120 else if (dwData == 1)
121 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 1;
122 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 0;
124 else if (dwData == 2)
125 { if (SSF_SHOWALLOBJECTS & dwMask) lpsfs->fShowAllObjects = 0;
126 if (SSF_SHOWSYSFILES & dwMask) lpsfs->fShowSysFiles = 1;
131 TRACE("-- 0x%04x\n", *(WORD*)lpsfs);
134 /*************************************************************************
135 * SHShellFolderView_Message [SHELL32.73]
138 * hwndCabinet defines the explorer cabinet window that contains the
139 * shellview you need to communicate with
140 * uMsg identifying the SFVM enum to perform
144 * Message SFVM_REARRANGE = 1
145 * This message gets sent when a column gets clicked to instruct the
146 * shell view to re-sort the item list. lParam identifies the column
149 int WINAPI SHShellFolderView_Message(HWND hwndCabinet,UINT uMsg,LPARAM lParam)
150 { FIXME("%04x %08ux %08lx stub\n",hwndCabinet,uMsg,lParam);
154 /*************************************************************************
155 * OleStrToStrN [SHELL32.78]
157 BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
159 TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
160 return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
163 BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
165 TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
167 if (lstrcpynW ( lpwStr, lpOle, nwStr))
168 { return lstrlenW (lpwStr);
173 BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
175 if (VERSION_OsIsUnicode())
176 return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
177 return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
180 /*************************************************************************
181 * StrToOleStrN [SHELL32.79]
182 * lpMulti, nMulti, nWide [IN]
185 BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
187 TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
188 return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
190 BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
192 TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
194 if (lstrcpynW (lpWide, lpStrW, nWide))
195 { return lstrlenW (lpWide);
200 BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
202 if (VERSION_OsIsUnicode())
203 return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
204 return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
207 /*************************************************************************
208 * RegisterShellHook [SHELL32.181]
211 * hwnd [I] window handle
215 * exported by ordinal
217 void WINAPI RegisterShellHook(HWND hwnd, DWORD y) {
218 FIXME("(0x%08x,0x%08lx):stub.\n",hwnd,y);
220 /*************************************************************************
221 * ShellMessageBoxW [SHELL32.182]
223 * Format and output errormessage.
225 * idText resource ID of title or LPSTR
226 * idTitle resource ID of title or LPSTR
229 * exported by ordinal
232 ShellMessageBoxW(HMODULE hmod,HWND hwnd,DWORD idText,DWORD idTitle,DWORD uType,LPCVOID arglist)
233 { WCHAR szText[100],szTitle[100],szTemp[256];
234 LPWSTR pszText = &szText[0], pszTitle = &szTitle[0];
235 LPVOID args = &arglist;
237 TRACE("(%08lx,%08lx,%08lx,%08lx,%08lx,%p)\n",(DWORD)hmod,(DWORD)hwnd,idText,idTitle,uType,arglist);
239 if (!HIWORD (idTitle))
240 LoadStringW(hmod,idTitle,pszTitle,100);
242 pszTitle = (LPWSTR)idTitle;
244 if (! HIWORD (idText))
245 LoadStringW(hmod,idText,pszText,100);
247 pszText = (LPWSTR)idText;
249 FormatMessageW(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY ,szText,0,0,szTemp,256,args);
250 return MessageBoxW(hwnd,szTemp,szTitle,uType);
253 /*************************************************************************
254 * ShellMessageBoxA [SHELL32.183]
257 ShellMessageBoxA(HMODULE hmod,HWND hwnd,DWORD idText,DWORD idTitle,DWORD uType,LPCVOID arglist)
258 { char szText[100],szTitle[100],szTemp[256];
259 LPSTR pszText = &szText[0], pszTitle = &szTitle[0];
260 LPVOID args = &arglist;
262 TRACE("(%08lx,%08lx,%08lx,%08lx,%08lx,%p)\n", (DWORD)hmod,(DWORD)hwnd,idText,idTitle,uType,arglist);
264 if (!HIWORD (idTitle))
265 LoadStringA(hmod,idTitle,pszTitle,100);
267 pszTitle = (LPSTR)idTitle;
269 if (! HIWORD (idText))
270 LoadStringA(hmod,idText,pszText,100);
272 pszText = (LPSTR)idText;
274 FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY ,pszText,0,0,szTemp,256,args);
275 return MessageBoxA(hwnd,szTemp,pszTitle,uType);
278 /*************************************************************************
279 * SHRestricted [SHELL32.100]
281 * walks through policy table, queries <app> key, <type> value, returns
282 * queried (DWORD) value, and caches it between called to SHInitRestricted
283 * to prevent unnecessary registry access.
286 * exported by ordinal
289 * MS System Policy Editor
290 * 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
291 * "The Windows 95 Registry", by John Woram, 1996 MIS: Press
293 DWORD WINAPI SHRestricted (DWORD pol) {
296 DWORD retval, polidx, i, datsize = 4;
298 TRACE("(%08lx)\n",pol);
302 /* scan to see if we know this policy ID */
303 for (i = 0; i < SHELL_MAX_POLICIES; i++)
305 if (pol == sh32_policy_table[i].polflags)
314 /* we don't know this policy, return 0 */
315 TRACE("unknown policy: (%08lx)\n", pol);
319 /* we have a known policy */
320 lstrcpyA(regstr, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
321 lstrcatA(regstr, sh32_policy_table[polidx].appstr);
323 /* first check if this policy has been cached, return it if so */
324 if (sh32_policy_table[polidx].cache != SHELL_NO_POLICY)
326 return sh32_policy_table[polidx].cache;
329 /* return 0 and don't set the cache if any registry errors occur */
331 if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
333 if (RegQueryValueExA(xhkey, sh32_policy_table[polidx].keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
335 sh32_policy_table[polidx].cache = retval;
344 /*************************************************************************
345 * SHInitRestricted [SHELL32.244]
347 * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
348 * Inits the policy cache used by SHRestricted to avoid excess
352 * Two inputs: one is a string or NULL. If non-NULL the pointer
353 * should point to a string containing the following exact text:
354 * "Software\Microsoft\Windows\CurrentVersion\Policies".
355 * The other input is unused.
358 * If the input is non-NULL and does not point to a string containing
359 * that exact text the routine will do nothing.
361 * If the text does match or the pointer is NULL, then the routine
362 * will init SHRestricted()'s policy cache to all 0xffffffff and
363 * returns 0xffffffff as well.
365 * I haven't yet run into anything calling this with inputs other than
366 * (NULL, NULL), so I may have the inputs reversed.
369 BOOL WINAPI SHInitRestricted(LPSTR inpRegKey, LPSTR parm2)
373 TRACE("(%p, %p)\n", inpRegKey, parm2);
375 /* first check - if input is non-NULL and points to the secret
376 key string, then pass. Otherwise return 0.
379 if (inpRegKey != (LPSTR)NULL)
381 if (lstrcmpiA(inpRegKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
383 /* doesn't match, fail */
388 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
389 for (i = 0; i < SHELL_MAX_POLICIES; i++)
391 sh32_policy_table[i].cache = SHELL_NO_POLICY;
394 return SHELL_NO_POLICY;
397 /*************************************************************************
398 * SHFree [SHELL32.195]
401 * free_ptr() - frees memory using IMalloc
402 * exported by ordinal
405 DWORD WINAPI SHFree(LPVOID x)
408 WORD len = *(LPWORD)((LPBYTE)x-2);
410 if ( *(LPWORD)((LPBYTE)x+len) != 0x7384)
413 if ( (*(LPWORD)((LPBYTE)x-4)) != 0x8271)
416 memset((LPBYTE)x-4, 0xde, len+6);
418 TRACE("%p len=%u\n",x, len);
424 return HeapFree(GetProcessHeap(), 0, x);
427 /*************************************************************************
428 * SHAlloc [SHELL32.196]
431 * void *task_alloc(DWORD len), uses SHMalloc allocator
432 * exported by ordinal
434 LPVOID WINAPI SHAlloc(DWORD len)
439 ret = (LPVOID) HeapAlloc(GetProcessHeap(),0,len+6);
441 ret = (LPVOID) HeapAlloc(GetProcessHeap(),0,len);
445 *(LPWORD)(ret) = 0x8271;
446 *(LPWORD)(ret+2) = (WORD)len;
447 *(LPWORD)(ret+4+len) = 0x7384;
449 memset(ret, 0xdf, len);
451 TRACE("%lu bytes at %p\n",len, ret);
455 /*************************************************************************
456 * SHRegisterDragDrop [SHELL32.86]
459 * exported by ordinal
461 DWORD WINAPI SHRegisterDragDrop(HWND hWnd,IDropTarget * pDropTarget)
463 FIXME("(0x%08x,%p):stub.\n", hWnd, pDropTarget);
464 if (GetShellOle()) return pRegisterDragDrop(hWnd, pDropTarget);
468 /*************************************************************************
469 * SHRevokeDragDrop [SHELL32.87]
472 * exported by ordinal
474 DWORD WINAPI SHRevokeDragDrop(DWORD x) {
475 FIXME("(0x%08lx):stub.\n",x);
479 /*************************************************************************
480 * SHDoDragDrop [SHELL32.88]
483 * exported by ordinal
485 DWORD WINAPI SHDoDragDrop(DWORD u, DWORD v, DWORD w, DWORD x, DWORD y, DWORD z) {
486 FIXME("(0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx 0x%08lx):stub.\n",u,v,w,x,y,z);
490 /*************************************************************************
491 * RunFileDlg [SHELL32.61]
494 * Original name: RunFileDlg (exported by ordinal)
497 RunFileDlg (HWND hwndOwner, DWORD dwParam1, DWORD dwParam2,
498 LPSTR lpszTitle, LPSTR lpszPrompt, UINT uFlags)
500 FIXME("(0x%08x 0x%lx 0x%lx \"%s\" \"%s\" 0x%x):stub.\n",
501 hwndOwner, dwParam1, dwParam2, lpszTitle, lpszPrompt, uFlags);
505 /*************************************************************************
506 * ExitWindowsDialog [SHELL32.60]
509 * exported by ordinal
511 void WINAPI ExitWindowsDialog (HWND hWndOwner)
513 TRACE("(0x%08x)\n", hWndOwner);
514 if (MessageBoxA( hWndOwner, "Do you want to exit WINE?", "Shutdown", MB_YESNO|MB_ICONQUESTION) == IDOK)
515 { SendMessageA ( hWndOwner, WM_QUIT, 0, 0);
519 /*************************************************************************
520 * ArrangeWindows [SHELL32.184]
524 ArrangeWindows (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3,
525 DWORD dwParam4, DWORD dwParam5)
527 FIXME("(0x%lx 0x%lx 0x%lx 0x%lx 0x%lx):stub.\n",
528 dwParam1, dwParam2, dwParam3, dwParam4, dwParam5);
532 /*************************************************************************
533 * SignalFileOpen [SHELL32.103]
536 * exported by ordinal
539 SignalFileOpen (DWORD dwParam1)
541 FIXME("(0x%08lx):stub.\n", dwParam1);
546 /*************************************************************************
547 * SHAddToRecentDocs [SHELL32.234]
550 * uFlags [IN] SHARD_PATH or SHARD_PIDL
551 * pv [IN] string or pidl, NULL clears the list
556 DWORD WINAPI SHAddToRecentDocs (UINT uFlags,LPCVOID pv)
557 { if (SHARD_PIDL==uFlags)
558 { FIXME("(0x%08x,pidl=%p):stub.\n", uFlags,pv);
561 { FIXME("(0x%08x,%s):stub.\n", uFlags,(char*)pv);
565 /*************************************************************************
566 * SHCreateShellFolderViewEx [SHELL32.174]
569 * see IShellFolder::CreateViewObject
571 HRESULT WINAPI SHCreateShellFolderViewEx(
572 LPSHELLVIEWDATA psvcbi, /*[in ] shelltemplate struct*/
573 LPVOID* ppv) /*[out] IShellView pointer*/
578 TRACE("sf=%p pidl=%p cb=%p mode=0x%08lx parm=0x%08lx\n",
579 psvcbi->pShellFolder, psvcbi->pidl, psvcbi->pCallBack, psvcbi->viewmode, psvcbi->dwUserParam);
581 psf = IShellView_Constructor(psvcbi->pShellFolder);
584 return E_OUTOFMEMORY;
586 IShellView_AddRef(psf);
587 hRes = IShellView_QueryInterface(psf, &IID_IShellView, (LPVOID *)ppv);
588 IShellView_Release(psf);
592 /*************************************************************************
593 * SHWinHelp [SHELL32.127]
596 HRESULT WINAPI SHWinHelp (DWORD v, DWORD w, DWORD x, DWORD z)
597 { FIXME("0x%08lx 0x%08lx 0x%08lx 0x%08lx stub\n",v,w,x,z);
600 /*************************************************************************
601 * SHRunControlPanel [SHELL32.161]
604 HRESULT WINAPI SHRunControlPanel (DWORD x, DWORD z)
605 { FIXME("0x%08lx 0x%08lx stub\n",x,z);
608 /*************************************************************************
609 * ShellExecuteEx [SHELL32.291]
612 BOOL WINAPI ShellExecuteExAW (LPVOID sei)
613 { if (VERSION_OsIsUnicode())
614 return ShellExecuteExW (sei);
615 return ShellExecuteExA (sei);
617 /*************************************************************************
618 * ShellExecuteExA [SHELL32.292]
620 * placeholder in the commandline:
625 * %I adress of a global item ID (explorer switch /idlist)
626 * %L ??? path/url/current file ???
628 * %* all following parameters (see batfile)
630 BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei)
631 { CHAR szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20];
634 STARTUPINFOA startup;
635 PROCESS_INFORMATION info;
637 WARN("mask=0x%08lx hwnd=0x%04x verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s incomplete\n",
638 sei->fMask, sei->hwnd, sei->lpVerb, sei->lpFile,
639 sei->lpParameters, sei->lpDirectory, sei->nShow,
640 (sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass : "not used");
642 ZeroMemory(szApplicationName,MAX_PATH);
644 strcpy(szApplicationName, sei->lpFile);
646 ZeroMemory(szCommandline,MAX_PATH);
647 if (sei->lpParameters)
648 strcpy(szCommandline, sei->lpParameters);
650 if (sei->fMask & (SEE_MASK_CLASSKEY | SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
651 SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
652 SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE |
653 SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR ))
655 FIXME("flags ignored: 0x%08lx\n", sei->fMask);
658 /* launch a document by fileclass like 'Wordpad.Document.1' */
659 if (sei->fMask & SEE_MASK_CLASSNAME)
661 /* the commandline contains 'c:\Path\wordpad.exe "%1"' */
662 HCR_GetExecuteCommand(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, 256);
663 /* fixme: get the extension of lpFile, check if it fits to the lpClass */
664 TRACE("SEE_MASK_CLASSNAME->'%s'\n", szCommandline);
667 /* process the IDList */
668 if ( (sei->fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST) /*0x0c*/
670 SHGetPathFromIDListA (sei->lpIDList,szApplicationName);
671 TRACE("-- idlist=%p (%s)\n", sei->lpIDList, szApplicationName);
675 if (sei->fMask & SEE_MASK_IDLIST )
677 pos = strstr(szCommandline, "%I");
680 HGLOBAL hmem = SHAllocShared ( sei->lpIDList, ILGetSize(sei->lpIDList), 0);
681 sprintf(szPidl,":%li",(DWORD)SHLockShared(hmem,0) );
682 SHUnlockShared(hmem);
684 gap = strlen(szPidl);
686 memmove(pos+gap,pos+2,len);
687 memcpy(pos,szPidl,gap);
693 TRACE("execute:'%s','%s'\n",szApplicationName, szCommandline);
695 strcat(szApplicationName, " ");
696 strcat(szApplicationName, szCommandline);
698 ZeroMemory(&startup,sizeof(STARTUPINFOA));
699 startup.cb = sizeof(STARTUPINFOA);
701 if (! CreateProcessA(NULL, szApplicationName,
702 NULL, NULL, FALSE, 0,
703 NULL, NULL, &startup, &info))
705 sei->hInstApp = GetLastError();
711 /* Give 30 seconds to the app to come up */
712 if ( WaitForInputIdle ( info.hProcess, 30000 ) == 0xFFFFFFFF )
713 ERR("WaitForInputIdle failed: Error %ld\n", GetLastError() );
715 if(sei->fMask & SEE_MASK_NOCLOSEPROCESS)
716 sei->hProcess = info.hProcess;
718 CloseHandle( info.hProcess );
719 CloseHandle( info.hThread );
722 /*************************************************************************
723 * ShellExecuteExW [SHELL32.293]
726 BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei)
727 { SHELLEXECUTEINFOA seiA;
732 memcpy(&seiA, sei, sizeof(SHELLEXECUTEINFOA));
735 seiA.lpVerb = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpVerb);
738 seiA.lpFile = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpFile);
740 if (sei->lpParameters)
741 seiA.lpParameters = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpParameters);
743 if (sei->lpDirectory)
744 seiA.lpDirectory = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpDirectory);
746 if ((sei->fMask & SEE_MASK_CLASSNAME) && sei->lpClass)
747 seiA.lpClass = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpClass);
751 ret = ShellExecuteExA(&seiA);
753 if (seiA.lpVerb) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpVerb );
754 if (seiA.lpFile) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpFile );
755 if (seiA.lpParameters) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpParameters );
756 if (seiA.lpDirectory) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpDirectory );
757 if (seiA.lpClass) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpClass );
762 static LPUNKNOWN SHELL32_IExplorerInterface=0;
763 /*************************************************************************
764 * SHSetInstanceExplorer [SHELL32.176]
769 HRESULT WINAPI SHSetInstanceExplorer (LPUNKNOWN lpUnknown)
770 { TRACE("%p\n", lpUnknown);
771 SHELL32_IExplorerInterface = lpUnknown;
772 return (HRESULT) lpUnknown;
774 /*************************************************************************
775 * SHGetInstanceExplorer [SHELL32.256]
778 * gets the interface pointer of the explorer and a reference
780 HRESULT WINAPI SHGetInstanceExplorer (LPUNKNOWN * lpUnknown)
781 { TRACE("%p\n", lpUnknown);
783 *lpUnknown = SHELL32_IExplorerInterface;
785 if (!SHELL32_IExplorerInterface)
788 IUnknown_AddRef(SHELL32_IExplorerInterface);
791 /*************************************************************************
792 * SHFreeUnusedLibraries [SHELL32.123]
797 HRESULT WINAPI SHFreeUnusedLibraries (void)
801 /*************************************************************************
802 * DAD_SetDragImage [SHELL32.136]
807 HRESULT WINAPI DAD_SetDragImage (DWORD u, DWORD v)
808 { FIXME("0x%08lx 0x%08lx stub\n",u, v);
811 /*************************************************************************
812 * DAD_ShowDragImage [SHELL32.137]
817 HRESULT WINAPI DAD_ShowDragImage (DWORD u)
818 { FIXME("0x%08lx stub\n",u);
821 /*************************************************************************
822 * SHRegCloseKey [NT4.0:SHELL32.505]
825 HRESULT WINAPI SHRegCloseKey (HKEY hkey)
826 { TRACE("0x%04x\n",hkey);
827 return RegCloseKey( hkey );
829 /*************************************************************************
830 * SHRegOpenKeyA [SHELL32.506]
833 HRESULT WINAPI SHRegOpenKeyA(HKEY hKey, LPSTR lpSubKey, LPHKEY phkResult)
835 TRACE("(0x%08x, %s, %p)\n", hKey, debugstr_a(lpSubKey), phkResult);
836 return RegOpenKeyA(hKey, lpSubKey, phkResult);
839 /*************************************************************************
840 * SHRegOpenKeyW [NT4.0:SHELL32.507]
843 HRESULT WINAPI SHRegOpenKeyW (HKEY hkey, LPCWSTR lpszSubKey, LPHKEY retkey)
844 { WARN("0x%04x %s %p\n",hkey,debugstr_w(lpszSubKey),retkey);
845 return RegOpenKeyW( hkey, lpszSubKey, retkey );
847 /*************************************************************************
848 * SHRegQueryValueExA [SHELL32.509]
851 HRESULT WINAPI SHRegQueryValueExA(
859 TRACE("0x%04x %s %p %p %p %p\n", hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
860 return RegQueryValueExA (hkey, lpValueName, lpReserved, lpType, lpData, lpcbData);
862 /*************************************************************************
863 * SHRegQueryValueW [NT4.0:SHELL32.510]
866 HRESULT WINAPI SHRegQueryValueW (HKEY hkey, LPWSTR lpszSubKey,
867 LPWSTR lpszData, LPDWORD lpcbData )
868 { WARN("0x%04x %s %p %p semi-stub\n",
869 hkey, debugstr_w(lpszSubKey), lpszData, lpcbData);
870 return RegQueryValueW( hkey, lpszSubKey, lpszData, lpcbData );
873 /*************************************************************************
874 * SHRegQueryValueExW [NT4.0:SHELL32.511]
877 * if the datatype REG_EXPAND_SZ then expand the string and change
878 * *pdwType to REG_SZ.
880 HRESULT WINAPI SHRegQueryValueExW (HKEY hkey, LPWSTR pszValue, LPDWORD pdwReserved,
881 LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData)
883 WARN("0x%04x %s %p %p %p %p semi-stub\n",
884 hkey, debugstr_w(pszValue), pdwReserved, pdwType, pvData, pcbData);
885 ret = RegQueryValueExW ( hkey, pszValue, pdwReserved, pdwType, pvData, pcbData);
889 /*************************************************************************
892 * Gets a value from the registry
894 DWORD WINAPI SHGetValueA(
903 FIXME("(%p),stub!\n", pSubKey);
905 return ERROR_SUCCESS; /* return success */
908 /*************************************************************************
911 * Gets a value from the registry
913 DWORD WINAPI SHGetValueW(
922 FIXME("(%p),stub!\n", pSubKey);
924 return ERROR_SUCCESS; /* return success */
927 /*************************************************************************
930 * Gets a user-specific registry value
932 LONG WINAPI SHRegGetUSValueA(
940 DWORD wDefaultDataSize
943 FIXME("(%p),stub!\n", pSubKey);
945 return ERROR_SUCCESS; /* return success */
948 /*************************************************************************
951 * Gets a user-specific registry value
953 LONG WINAPI SHRegGetUSValueW(
961 DWORD wDefaultDataSize
964 FIXME("(%p),stub!\n", pSubKey);
966 return ERROR_SUCCESS; /* return success */
969 /*************************************************************************
970 * SHRegDeleteKeyA and SHDeleteKeyA
972 HRESULT WINAPI SHRegDeleteKeyA(HKEY hkey, LPCSTR pszSubKey)
974 FIXME("hkey=0x%08x, %s\n", hkey, debugstr_a(pszSubKey));
978 /*************************************************************************
979 * SHRegDeleteKeyW and SHDeleteKeyA
981 HRESULT WINAPI SHRegDeleteKeyW(HKEY hkey, LPCWSTR pszSubKey)
983 FIXME("hkey=0x%08x, %s\n", hkey, debugstr_w(pszSubKey));
986 /*************************************************************************
987 * ReadCabinetState [NT 4.0:SHELL32.651]
990 HRESULT WINAPI ReadCabinetState(DWORD u, DWORD v)
991 { FIXME("0x%04lx 0x%04lx stub\n",u,v);
994 /*************************************************************************
995 * WriteCabinetState [NT 4.0:SHELL32.652]
998 HRESULT WINAPI WriteCabinetState(DWORD u)
999 { FIXME("0x%04lx stub\n",u);
1002 /*************************************************************************
1003 * FileIconInit [SHELL32.660]
1006 BOOL WINAPI FileIconInit(BOOL bFullInit)
1007 { FIXME("(%s)\n", bFullInit ? "true" : "false");
1010 /*************************************************************************
1011 * IsUserAdmin [NT 4.0:SHELL32.680]
1014 HRESULT WINAPI IsUserAdmin(void)
1019 /*************************************************************************
1020 * StrRetToBufA [SHLWAPI.@]
1022 * converts a STRRET to a normal string
1025 * the pidl is for STRRET OFFSET
1027 HRESULT WINAPI StrRetToBufA (LPSTRRET src, LPITEMIDLIST pidl, LPSTR dest, DWORD len)
1029 return StrRetToStrNA(dest, len, src, pidl);
1032 /*************************************************************************
1033 * StrRetToBufW [SHLWAPI.@]
1035 * converts a STRRET to a normal string
1038 * the pidl is for STRRET OFFSET
1040 HRESULT WINAPI StrRetToBufW (LPSTRRET src, LPITEMIDLIST pidl, LPWSTR dest, DWORD len)
1042 return StrRetToStrNW(dest, len, src, pidl);
1045 /*************************************************************************
1046 * StrRetToStrN [SHELL32.96]
1048 * converts a STRRET to a normal string
1051 * the pidl is for STRRET OFFSET
1053 HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
1055 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
1060 WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
1061 SHFree(src->u.pOleStr);
1065 lstrcpynA((LPSTR)dest, src->u.cStr, len);
1068 case STRRET_OFFSETA:
1069 lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
1073 FIXME("unknown type!\n");
1076 *(LPSTR)dest = '\0';
1083 HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
1085 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
1090 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
1091 SHFree(src->u.pOleStr);
1095 lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
1098 case STRRET_OFFSETA:
1101 lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
1106 FIXME("unknown type!\n");
1108 { *(LPSTR)dest = '\0';
1114 HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
1116 if(VERSION_OsIsUnicode())
1117 return StrRetToStrNW (dest, len, src, pidl);
1118 return StrRetToStrNA (dest, len, src, pidl);
1121 /*************************************************************************
1122 * StrChrW [NT 4.0:SHELL32.651]
1125 LPWSTR WINAPI StrChrW (LPWSTR str, WCHAR x )
1127 TRACE("%s 0x%04x\n",debugstr_w(str),x);
1128 return CRTDLL_wcschr(str, x);
1131 /*************************************************************************
1132 * StrCmpNIW [NT 4.0:SHELL32.*]
1135 INT WINAPI StrCmpNIW ( LPWSTR wstr1, LPWSTR wstr2, INT len)
1137 TRACE("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
1138 return CRTDLL__wcsnicmp(wstr1, wstr2, len);
1141 /*************************************************************************
1142 * SHAllocShared [SHELL32.520]
1145 * parameter1 is return value from HeapAlloc
1146 * parameter2 is equal to the size allocated with HeapAlloc
1147 * parameter3 is return value from GetCurrentProcessId
1149 * the return value is posted as lParam with 0x402 (WM_USER+2) to somewhere
1150 * WM_USER+2 could be the undocumented CWM_SETPATH
1151 * the allocated memory contains a pidl
1153 HGLOBAL WINAPI SHAllocShared(LPVOID psrc, DWORD size, DWORD procID)
1157 TRACE("ptr=%p size=0x%04lx procID=0x%04lx\n",psrc,size,procID);
1158 hmem = GlobalAlloc(GMEM_FIXED, size);
1162 pmem = GlobalLock (hmem);
1167 memcpy (pmem, psrc, size);
1171 /*************************************************************************
1172 * SHLockShared [SHELL32.521]
1175 * parameter1 is return value from SHAllocShared
1176 * parameter2 is return value from GetCurrentProcessId
1177 * the receiver of (WM_USER+2) trys to lock the HANDLE (?)
1178 * the returnvalue seems to be a memoryadress
1180 LPVOID WINAPI SHLockShared(HANDLE hmem, DWORD procID)
1181 { TRACE("handle=0x%04x procID=0x%04lx\n",hmem,procID);
1182 return GlobalLock(hmem);
1184 /*************************************************************************
1185 * SHUnlockShared [SHELL32.522]
1188 * parameter1 is return value from SHLockShared
1190 BOOL WINAPI SHUnlockShared(HANDLE pmem)
1191 { TRACE("handle=0x%04x\n",pmem);
1192 return GlobalUnlock(pmem);
1194 /*************************************************************************
1195 * SHFreeShared [SHELL32.523]
1198 * parameter1 is return value from SHAllocShared
1199 * parameter2 is return value from GetCurrentProcessId
1201 HANDLE WINAPI SHFreeShared(HANDLE hmem, DWORD procID)
1202 { TRACE("handle=0x%04x 0x%04lx\n",hmem,procID);
1203 return GlobalFree(hmem);
1206 /*************************************************************************
1207 * SetAppStartingCursor [SHELL32.99]
1210 HRESULT WINAPI SetAppStartingCursor(HWND u, DWORD v)
1211 { FIXME("hwnd=0x%04x 0x%04lx stub\n",u,v );
1214 /*************************************************************************
1215 * SHLoadOLE [SHELL32.151]
1218 HRESULT WINAPI SHLoadOLE(DWORD u)
1219 { FIXME("0x%04lx stub\n",u);
1222 /*************************************************************************
1223 * DriveType [SHELL32.64]
1226 HRESULT WINAPI DriveType(DWORD u)
1227 { FIXME("0x%04lx stub\n",u);
1230 /*************************************************************************
1231 * SHAbortInvokeCommand [SHELL32.198]
1234 HRESULT WINAPI SHAbortInvokeCommand(void)
1238 /*************************************************************************
1239 * SHOutOfMemoryMessageBox [SHELL32.126]
1242 HRESULT WINAPI SHOutOfMemoryMessageBox(DWORD u, DWORD v, DWORD w)
1243 { FIXME("0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w);
1246 /*************************************************************************
1247 * SHFlushClipboard [SHELL32.121]
1250 HRESULT WINAPI SHFlushClipboard(void)
1255 /*************************************************************************
1256 * StrFormatByteSizeA [SHLWAPI]
1258 LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
1260 TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
1262 { sprintf (buf,"%3.1f bytes", (FLOAT)dw);
1264 else if ( dw<1048576L)
1265 { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
1267 else if ( dw < 1073741824L)
1268 { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
1271 { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
1273 lstrcpynA (pszBuf, buf, cchBuf);
1277 /*************************************************************************
1278 * StrFormatByteSizeW [SHLWAPI]
1280 LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
1282 TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
1284 { sprintf (buf,"%3.1f bytes", (FLOAT)dw);
1286 else if ( dw<1048576L)
1287 { sprintf (buf,"%3.1f KB", (FLOAT)dw/1024);
1289 else if ( dw < 1073741824L)
1290 { sprintf (buf,"%3.1f MB", (FLOAT)dw/1048576L);
1293 { sprintf (buf,"%3.1f GB", (FLOAT)dw/1073741824L);
1295 lstrcpynAtoW (pszBuf, buf, cchBuf);
1298 /*************************************************************************
1299 * SHWaitForFileToOpen [SHELL32.97]
1302 HRESULT WINAPI SHWaitForFileToOpen(DWORD u, DWORD v, DWORD w)
1303 { FIXME("0x%04lx 0x%04lx 0x%04lx stub\n",u,v,w);
1306 /*************************************************************************
1307 * Control_FillCache_RunDLL [SHELL32.8]
1310 HRESULT WINAPI Control_FillCache_RunDLL(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
1311 { FIXME("0x%04x 0x%04x 0x%04lx 0x%04lx stub\n",hWnd, hModule,w,x);
1314 /*************************************************************************
1315 * RunDLL_CallEntry16 [SHELL32.122]
1316 * the name is propably wrong
1318 HRESULT WINAPI RunDLL_CallEntry16(DWORD v, DWORD w, DWORD x, DWORD y, DWORD z)
1319 { FIXME("0x%04lx 0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",v,w,x,y,z);
1323 /************************************************************************
1324 * shell32_654 [SHELL32.654]
1326 * NOTES: first parameter seems to be a pointer (same as passed to WriteCabinetState)
1327 * second one could be a size (0x0c). The size is the same as the structure saved to
1328 * HCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
1329 * I'm (js) guessing: this one is just ReadCabinetState ;-)
1331 HRESULT WINAPI shell32_654 (DWORD x, DWORD y)
1332 { FIXME("0x%08lx 0x%08lx stub\n",x,y);
1336 /************************************************************************
1337 * RLBuildListOfPaths [SHELL32.146]
1342 DWORD WINAPI RLBuildListOfPaths (void)
1346 /************************************************************************
1347 * StrToOleStr [SHELL32.163]
1350 int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
1352 TRACE("(%p, %p %s)\n",
1353 lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
1355 return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
1358 int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
1360 TRACE("(%p, %p %s)\n",
1361 lpWideCharStr, lpWString, debugstr_w(lpWString));
1363 if (lstrcpyW (lpWideCharStr, lpWString ))
1364 { return lstrlenW (lpWideCharStr);
1369 BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
1371 if (VERSION_OsIsUnicode())
1372 return StrToOleStrW (lpWideCharStr, lpString);
1373 return StrToOleStrA (lpWideCharStr, lpString);
1376 /************************************************************************
1377 * SHValidateUNC [SHELL32.173]
1380 HRESULT WINAPI SHValidateUNC (DWORD x, DWORD y, DWORD z)
1382 FIXME("0x%08lx 0x%08lx 0x%08lx stub\n",x,y,z);
1386 /************************************************************************
1387 * DoEnvironmentSubstA [SHELL32.1222]
1390 HRESULT WINAPI DoEnvironmentSubstA(LPSTR x, LPSTR y)
1392 FIXME("(%p %s, %p %s) stub\n", x, debugstr_a(x), y, debugstr_a(y));
1396 /************************************************************************
1397 * DoEnvironmentSubstW [SHELL32.1223]
1400 HRESULT WINAPI DoEnvironmentSubstW(LPWSTR x, LPWSTR y)
1402 FIXME("(%p %s, %p %s) stub\n", x, debugstr_w(x), y, debugstr_w(y));
1406 /************************************************************************
1407 * DoEnvironmentSubst [SHELL32.53]
1410 HRESULT WINAPI DoEnvironmentSubstAW(LPVOID x, LPVOID y)
1412 if (VERSION_OsIsUnicode())
1413 return DoEnvironmentSubstW(x, y);
1414 return DoEnvironmentSubstA(x, y);
1417 /*************************************************************************
1418 * shell32_243 [SHELL32.243]
1420 * Win98+ by-ordinal routine. In Win98 this routine returns zero and
1421 * does nothing else. Possibly this does something in NT or SHELL32 5.0?
1425 BOOL WINAPI shell32_243(DWORD a, DWORD b)