widl: Always write out pointers if the structure is a pointer structure. Pointer...
[wine/multimedia.git] / dlls / shell32 / shellole.c
blobe5d8368202d5002bcecce91fa01b1692160bd2d2
1 /*
2 * handling of SHELL32.DLL OLE-Objects
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied <juergen.schmied@metronet.de>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <string.h>
28 #define COBJMACROS
30 #include "windef.h"
31 #include "winbase.h"
32 #include "shellapi.h"
33 #include "wingdi.h"
34 #include "winuser.h"
35 #include "shlobj.h"
36 #include "shlguid.h"
37 #include "winreg.h"
38 #include "winerror.h"
40 #include "undocshell.h"
41 #include "wine/unicode.h"
42 #include "shell32_main.h"
44 #include "wine/debug.h"
45 #include "shlwapi.h"
46 #include "debughlp.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(shell);
50 extern HRESULT WINAPI IFSFolder_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
52 static const WCHAR sShell32[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
54 /**************************************************************************
55 * Default ClassFactory types
57 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
58 static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst);
60 /* this table contains all CLSID's of shell32 objects */
61 static const struct {
62 REFIID riid;
63 LPFNCREATEINSTANCE lpfnCI;
64 } InterfaceTable[] = {
65 {&CLSID_ShellFSFolder, &IFSFolder_Constructor},
66 {&CLSID_MyComputer, &ISF_MyComputer_Constructor},
67 {&CLSID_ShellDesktop, &ISF_Desktop_Constructor},
68 {&CLSID_ShellLink, &IShellLink_Constructor},
69 {&CLSID_DragDropHelper, &IDropTargetHelper_Constructor},
70 {&CLSID_ControlPanel, &IControlPanel_Constructor},
71 {&CLSID_AutoComplete, &IAutoComplete_Constructor},
72 {&CLSID_UnixFolder, &UnixFolder_Constructor},
73 {&CLSID_UnixDosFolder, &UnixDosFolder_Constructor},
74 {&CLSID_FolderShortcut, &FolderShortcut_Constructor},
75 {&CLSID_MyDocuments, &MyDocuments_Constructor},
76 {&CLSID_RecycleBin, &RecycleBin_Constructor},
77 {NULL,NULL}
81 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
83 DWORD WINAPI __SHGUIDToStringW (REFGUID guid, LPWSTR str)
85 WCHAR sFormat[52] = {'{','%','0','8','l','x','-','%','0','4',
86 'x','-','%','0','4','x','-','%','0','2',
87 'x','%','0','2','x','-','%','0','2','x',
88 '%','0','2','x','%','0','2','x','%','0',
89 '2','x','%','0','2','x','%','0','2','x',
90 '}','\0'};
92 return wsprintfW ( str, sFormat,
93 guid->Data1, guid->Data2, guid->Data3,
94 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
95 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
99 /*************************************************************************
100 * SHCoCreateInstance [SHELL32.102]
102 * Equivalent to CoCreateInstance. Under Windows 9x this function could sometimes
103 * use the shell32 built-in "mini-COM" without the need to load ole32.dll - see
104 * SHLoadOLE for details.
106 * Under wine if a "LoadWithoutCOM" value is present or the object resides in
107 * shell32.dll the function will load the object manually without the help of ole32
109 * NOTES
110 * exported by ordinal
112 * SEE ALSO
113 * CoCreateInstace, SHLoadOLE
115 HRESULT WINAPI SHCoCreateInstance(
116 LPCWSTR aclsid,
117 const CLSID *clsid,
118 LPUNKNOWN pUnkOuter,
119 REFIID refiid,
120 LPVOID *ppv)
122 DWORD hres;
123 IID iid;
124 const CLSID * myclsid = clsid;
125 WCHAR sKeyName[MAX_PATH];
126 const WCHAR sCLSID[7] = {'C','L','S','I','D','\\','\0'};
127 WCHAR sClassID[60];
128 const WCHAR sInProcServer32[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
129 const WCHAR sLoadWithoutCOM[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
130 WCHAR sDllPath[MAX_PATH];
131 HKEY hKey;
132 DWORD dwSize;
133 BOOLEAN bLoadFromShell32 = FALSE;
134 BOOLEAN bLoadWithoutCOM = FALSE;
135 IClassFactory * pcf = NULL;
137 if(!ppv) return E_POINTER;
138 *ppv=NULL;
140 /* if the clsid is a string, convert it */
141 if (!clsid)
143 if (!aclsid) return REGDB_E_CLASSNOTREG;
144 SHCLSIDFromStringW(aclsid, &iid);
145 myclsid = &iid;
148 TRACE("(%p,%s,unk:%p,%s,%p)\n",
149 aclsid,shdebugstr_guid(myclsid),pUnkOuter,shdebugstr_guid(refiid),ppv);
151 /* we look up the dll path in the registry */
152 __SHGUIDToStringW(myclsid, sClassID);
153 lstrcpyW(sKeyName, sCLSID);
154 lstrcatW(sKeyName, sClassID);
155 lstrcatW(sKeyName, sInProcServer32);
157 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, sKeyName, 0, KEY_READ, &hKey)) {
158 dwSize = sizeof(sDllPath);
159 SHQueryValueExW(hKey, NULL, 0,0, sDllPath, &dwSize );
161 /* if a special registry key is set, we load a shell extension without help of OLE32 */
162 bLoadWithoutCOM = (ERROR_SUCCESS == SHQueryValueExW(hKey, sLoadWithoutCOM, 0, 0, 0, 0));
164 /* if the com object is inside shell32, omit use of ole32 */
165 bLoadFromShell32 = (0==lstrcmpiW( PathFindFileNameW(sDllPath), sShell32));
167 RegCloseKey (hKey);
168 } else {
169 /* since we can't find it in the registry we try internally */
170 bLoadFromShell32 = TRUE;
173 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
175 /* now we create an instance */
176 if (bLoadFromShell32) {
177 if (! SUCCEEDED(DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
178 ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid));
180 } else if (bLoadWithoutCOM) {
182 /* load an external dll without ole32 */
183 HANDLE hLibrary;
184 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
185 DllGetClassObjectFunc DllGetClassObject;
187 if ((hLibrary = LoadLibraryExW(sDllPath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) {
188 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath));
189 hres = E_ACCESSDENIED;
190 goto end;
191 } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) {
192 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath));
193 FreeLibrary( hLibrary );
194 hres = E_ACCESSDENIED;
195 goto end;
196 } else if (! SUCCEEDED(hres = DllGetClassObject(myclsid, &IID_IClassFactory, (LPVOID*)&pcf))) {
197 TRACE("GetClassObject failed 0x%08x\n", hres);
198 goto end;
201 } else {
203 /* load an external dll in the usual way */
204 hres = CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv);
205 goto end;
208 /* here we should have a ClassFactory */
209 if (!pcf) return E_ACCESSDENIED;
211 hres = IClassFactory_CreateInstance(pcf, pUnkOuter, refiid, ppv);
212 IClassFactory_Release(pcf);
213 end:
214 if(hres!=S_OK)
216 ERR("failed (0x%08x) to create CLSID:%s IID:%s\n",
217 hres, shdebugstr_guid(myclsid), shdebugstr_guid(refiid));
218 ERR("class not found in registry\n");
221 TRACE("-- instance: %p\n",*ppv);
222 return hres;
225 /*************************************************************************
226 * DllGetClassObject [SHELL32.@]
227 * SHDllGetClassObject [SHELL32.128]
229 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
231 HRESULT hres = E_OUTOFMEMORY;
232 IClassFactory * pcf = NULL;
233 int i;
235 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid),shdebugstr_guid(iid));
237 if (!ppv) return E_INVALIDARG;
238 *ppv = NULL;
240 /* search our internal interface table */
241 for(i=0;InterfaceTable[i].riid;i++) {
242 if(IsEqualIID(InterfaceTable[i].riid, rclsid)) {
243 TRACE("index[%u]\n", i);
244 pcf = IDefClF_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
248 if (!pcf) {
249 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid));
250 return CLASS_E_CLASSNOTAVAILABLE;
253 hres = IClassFactory_QueryInterface(pcf, iid, ppv);
254 IClassFactory_Release(pcf);
256 TRACE("-- pointer to class factory: %p\n",*ppv);
257 return hres;
260 /*************************************************************************
261 * SHCLSIDFromString [SHELL32.147]
263 * Under Windows 9x this was an ANSI version of CLSIDFromString. It also allowed
264 * to avoid dependency on ole32.dll (see SHLoadOLE for details).
266 * Under Windows NT/2000/XP this is equivalent to CLSIDFromString
268 * NOTES
269 * exported by ordinal
271 * SEE ALSO
272 * CLSIDFromString, SHLoadOLE
274 DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id)
276 WCHAR buffer[40];
277 TRACE("(%p(%s) %p)\n", clsid, clsid, id);
278 if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) ))
279 return CO_E_CLASSSTRING;
280 return CLSIDFromString( buffer, id );
282 DWORD WINAPI SHCLSIDFromStringW (LPCWSTR clsid, CLSID *id)
284 TRACE("(%p(%s) %p)\n", clsid, debugstr_w(clsid), id);
285 return CLSIDFromString((LPWSTR)clsid, id);
287 DWORD WINAPI SHCLSIDFromStringAW (LPVOID clsid, CLSID *id)
289 if (SHELL_OsIsUnicode())
290 return SHCLSIDFromStringW (clsid, id);
291 return SHCLSIDFromStringA (clsid, id);
294 /*************************************************************************
295 * SHGetMalloc [SHELL32.@]
297 * Equivalent to CoGetMalloc(MEMCTX_TASK, ...). Under Windows 9x this function
298 * could use the shell32 built-in "mini-COM" without the need to load ole32.dll -
299 * see SHLoadOLE for details.
301 * PARAMS
302 * lpmal [O] Destination for IMalloc interface.
304 * RETURNS
305 * Success: S_OK. lpmal contains the shells IMalloc interface.
306 * Failure. An HRESULT error code.
308 * SEE ALSO
309 * CoGetMalloc, SHLoadOLE
311 HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal)
313 TRACE("(%p)\n", lpmal);
314 return CoGetMalloc(MEMCTX_TASK, lpmal);
317 /*************************************************************************
318 * SHAlloc [SHELL32.196]
320 * Equivalent to CoTaskMemAlloc. Under Windows 9x this function could use
321 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
322 * see SHLoadOLE for details.
324 * NOTES
325 * exported by ordinal
327 * SEE ALSO
328 * CoTaskMemAlloc, SHLoadOLE
330 LPVOID WINAPI SHAlloc(DWORD len)
332 LPVOID ret;
334 ret = CoTaskMemAlloc(len);
335 TRACE("%u bytes at %p\n",len, ret);
336 return ret;
339 /*************************************************************************
340 * SHFree [SHELL32.195]
342 * Equivalent to CoTaskMemFree. Under Windows 9x this function could use
343 * the shell32 built-in "mini-COM" without the need to load ole32.dll -
344 * see SHLoadOLE for details.
346 * NOTES
347 * exported by ordinal
349 * SEE ALSO
350 * CoTaskMemFree, SHLoadOLE
352 void WINAPI SHFree(LPVOID pv)
354 TRACE("%p\n",pv);
355 CoTaskMemFree(pv);
358 /*************************************************************************
359 * SHGetDesktopFolder [SHELL32.@]
361 HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
363 HRESULT hres = S_OK;
364 TRACE("\n");
366 if(!psf) return E_INVALIDARG;
367 *psf = NULL;
368 hres = ISF_Desktop_Constructor(NULL, &IID_IShellFolder,(LPVOID*)psf);
370 TRACE("-- %p->(%p)\n",psf, *psf);
371 return hres;
373 /**************************************************************************
374 * Default ClassFactory Implementation
376 * SHCreateDefClassObject
378 * NOTES
379 * Helper function for dlls without their own classfactory.
380 * A generic classfactory is returned.
381 * When the CreateInstance of the cf is called the callback is executed.
384 typedef struct
386 const IClassFactoryVtbl *lpVtbl;
387 LONG ref;
388 CLSID *rclsid;
389 LPFNCREATEINSTANCE lpfnCI;
390 const IID * riidInst;
391 LONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
392 } IDefClFImpl;
394 static const IClassFactoryVtbl dclfvt;
396 /**************************************************************************
397 * IDefClF_fnConstructor
400 static IClassFactory * IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
402 IDefClFImpl* lpclf;
404 lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
405 lpclf->ref = 1;
406 lpclf->lpVtbl = &dclfvt;
407 lpclf->lpfnCI = lpfnCI;
408 lpclf->pcRefDll = pcRefDll;
410 if (pcRefDll) InterlockedIncrement(pcRefDll);
411 lpclf->riidInst = riidInst;
413 TRACE("(%p)%s\n",lpclf, shdebugstr_guid(riidInst));
414 return (LPCLASSFACTORY)lpclf;
416 /**************************************************************************
417 * IDefClF_fnQueryInterface
419 static HRESULT WINAPI IDefClF_fnQueryInterface(
420 LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
422 IDefClFImpl *This = (IDefClFImpl *)iface;
424 TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid));
426 *ppvObj = NULL;
428 if(IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) {
429 *ppvObj = This;
430 InterlockedIncrement(&This->ref);
431 return S_OK;
434 TRACE("-- E_NOINTERFACE\n");
435 return E_NOINTERFACE;
437 /******************************************************************************
438 * IDefClF_fnAddRef
440 static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
442 IDefClFImpl *This = (IDefClFImpl *)iface;
443 ULONG refCount = InterlockedIncrement(&This->ref);
445 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
447 return refCount;
449 /******************************************************************************
450 * IDefClF_fnRelease
452 static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
454 IDefClFImpl *This = (IDefClFImpl *)iface;
455 ULONG refCount = InterlockedDecrement(&This->ref);
457 TRACE("(%p)->(count=%u)\n", This, refCount + 1);
459 if (!refCount)
461 if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
463 TRACE("-- destroying IClassFactory(%p)\n",This);
464 HeapFree(GetProcessHeap(),0,This);
465 return 0;
467 return refCount;
469 /******************************************************************************
470 * IDefClF_fnCreateInstance
472 static HRESULT WINAPI IDefClF_fnCreateInstance(
473 LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
475 IDefClFImpl *This = (IDefClFImpl *)iface;
477 TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject);
479 *ppvObject = NULL;
481 if ( This->riidInst==NULL ||
482 IsEqualCLSID(riid, This->riidInst) ||
483 IsEqualCLSID(riid, &IID_IUnknown) )
485 return This->lpfnCI(pUnkOuter, riid, ppvObject);
488 ERR("unknown IID requested %s\n",shdebugstr_guid(riid));
489 return E_NOINTERFACE;
491 /******************************************************************************
492 * IDefClF_fnLockServer
494 static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
496 IDefClFImpl *This = (IDefClFImpl *)iface;
497 TRACE("%p->(0x%x), not implemented\n",This, fLock);
498 return E_NOTIMPL;
501 static const IClassFactoryVtbl dclfvt =
503 IDefClF_fnQueryInterface,
504 IDefClF_fnAddRef,
505 IDefClF_fnRelease,
506 IDefClF_fnCreateInstance,
507 IDefClF_fnLockServer
510 /******************************************************************************
511 * SHCreateDefClassObject [SHELL32.70]
513 HRESULT WINAPI SHCreateDefClassObject(
514 REFIID riid,
515 LPVOID* ppv,
516 LPFNCREATEINSTANCE lpfnCI, /* [in] create instance callback entry */
517 LPDWORD pcRefDll, /* [in/out] ref count of the dll */
518 REFIID riidInst) /* [in] optional interface to the instance */
520 IClassFactory * pcf;
522 TRACE("%s %p %p %p %s\n",
523 shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst));
525 if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
526 if (! (pcf = IDefClF_fnConstructor(lpfnCI, (PLONG)pcRefDll, riidInst))) return E_OUTOFMEMORY;
527 *ppv = pcf;
528 return NOERROR;
531 /*************************************************************************
532 * DragAcceptFiles [SHELL32.@]
534 void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
536 LONG exstyle;
538 if( !IsWindow(hWnd) ) return;
539 exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
540 if (b)
541 exstyle |= WS_EX_ACCEPTFILES;
542 else
543 exstyle &= ~WS_EX_ACCEPTFILES;
544 SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
547 /*************************************************************************
548 * DragFinish [SHELL32.@]
550 void WINAPI DragFinish(HDROP h)
552 TRACE("\n");
553 GlobalFree((HGLOBAL)h);
556 /*************************************************************************
557 * DragQueryPoint [SHELL32.@]
559 BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
561 DROPFILES *lpDropFileStruct;
562 BOOL bRet;
564 TRACE("\n");
566 lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
568 *p = lpDropFileStruct->pt;
569 bRet = lpDropFileStruct->fNC;
571 GlobalUnlock(hDrop);
572 return bRet;
575 /*************************************************************************
576 * DragQueryFileA [SHELL32.@]
577 * DragQueryFile [SHELL32.@]
579 UINT WINAPI DragQueryFileA(
580 HDROP hDrop,
581 UINT lFile,
582 LPSTR lpszFile,
583 UINT lLength)
585 LPSTR lpDrop;
586 UINT i = 0;
587 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
589 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);
591 if(!lpDropFileStruct) goto end;
593 lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
595 if(lpDropFileStruct->fWide) {
596 LPWSTR lpszFileW = NULL;
598 if(lpszFile) {
599 lpszFileW = HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
600 if(lpszFileW == NULL) {
601 goto end;
604 i = DragQueryFileW(hDrop, lFile, lpszFileW, lLength);
606 if(lpszFileW) {
607 WideCharToMultiByte(CP_ACP, 0, lpszFileW, -1, lpszFile, lLength, 0, NULL);
608 HeapFree(GetProcessHeap(), 0, lpszFileW);
610 goto end;
613 while (i++ < lFile)
615 while (*lpDrop++); /* skip filename */
616 if (!*lpDrop)
618 i = (lFile == 0xFFFFFFFF) ? i : 0;
619 goto end;
623 i = strlen(lpDrop);
624 i++;
625 if (!lpszFile ) goto end; /* needed buffer size */
626 i = (lLength > i) ? i : lLength;
627 lstrcpynA (lpszFile, lpDrop, i);
628 end:
629 GlobalUnlock(hDrop);
630 return i;
633 /*************************************************************************
634 * DragQueryFileW [SHELL32.@]
636 UINT WINAPI DragQueryFileW(
637 HDROP hDrop,
638 UINT lFile,
639 LPWSTR lpszwFile,
640 UINT lLength)
642 LPWSTR lpwDrop;
643 UINT i = 0;
644 DROPFILES *lpDropFileStruct = (DROPFILES *) GlobalLock(hDrop);
646 TRACE("(%p, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
648 if(!lpDropFileStruct) goto end;
650 lpwDrop = (LPWSTR) ((LPSTR)lpDropFileStruct + lpDropFileStruct->pFiles);
652 if(lpDropFileStruct->fWide == FALSE) {
653 LPSTR lpszFileA = NULL;
655 if(lpszwFile) {
656 lpszFileA = HeapAlloc(GetProcessHeap(), 0, lLength);
657 if(lpszFileA == NULL) {
658 goto end;
661 i = DragQueryFileA(hDrop, lFile, lpszFileA, lLength);
663 if(lpszFileA) {
664 MultiByteToWideChar(CP_ACP, 0, lpszFileA, -1, lpszwFile, lLength);
665 HeapFree(GetProcessHeap(), 0, lpszFileA);
667 goto end;
670 i = 0;
671 while (i++ < lFile)
673 while (*lpwDrop++); /* skip filename */
674 if (!*lpwDrop)
676 i = (lFile == 0xFFFFFFFF) ? i : 0;
677 goto end;
681 i = strlenW(lpwDrop);
682 i++;
683 if ( !lpszwFile) goto end; /* needed buffer size */
685 i = (lLength > i) ? i : lLength;
686 lstrcpynW (lpszwFile, lpwDrop, i);
687 end:
688 GlobalUnlock(hDrop);
689 return i;