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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 #include "undocshell.h"
41 #include "wine/unicode.h"
42 #include "shell32_main.h"
44 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
50 extern HRESULT WINAPI
IFSFolder_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
);
52 const WCHAR sShell32
[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
53 const WCHAR sOLE32
[10] = {'O','L','E','3','2','.','D','L','L','\0'};
55 HINSTANCE hShellOle32
= 0;
56 /**************************************************************************
57 * Default ClassFactory types
59 typedef HRESULT (CALLBACK
*LPFNCREATEINSTANCE
)(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppvObject
);
60 IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
);
62 /* this table contains all CLSID's of shell32 objects */
65 LPFNCREATEINSTANCE lpfnCI
;
66 } InterfaceTable
[] = {
67 {&CLSID_ShellFSFolder
, &IFSFolder_Constructor
},
68 {&CLSID_MyComputer
, &ISF_MyComputer_Constructor
},
69 {&CLSID_ShellDesktop
, &ISF_Desktop_Constructor
},
70 {&CLSID_ShellLink
, &IShellLink_Constructor
},
71 {&CLSID_DragDropHelper
, &IDropTargetHelper_Constructor
},
72 {&CLSID_ControlPanel
, &IControlPanel_Constructor
},
73 {&CLSID_AutoComplete
, &IAutoComplete_Constructor
},
77 /*************************************************************************
78 * SHCoCreateInstance [SHELL32.102]
84 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
86 DWORD WINAPI
__SHGUIDToStringW (REFGUID guid
, LPWSTR str
)
88 WCHAR sFormat
[52] = {'{','%','0','8','l','x','-','%','0','4',
89 'x','-','%','0','4','x','-','%','0','2',
90 'x','%','0','2','x','-','%','0','2','x',
91 '%','0','2','x','%','0','2','x','%','0',
92 '2','x','%','0','2','x','%','0','2','x',
95 return wsprintfW ( str
, sFormat
,
96 guid
->Data1
, guid
->Data2
, guid
->Data3
,
97 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
98 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7] );
102 /************************************************************************/
104 HRESULT WINAPI
SHCoCreateInstance(
113 CLSID
* myclsid
= (CLSID
*)clsid
;
114 WCHAR sKeyName
[MAX_PATH
];
115 const WCHAR sCLSID
[7] = {'C','L','S','I','D','\\','\0'};
117 const WCHAR sInProcServer32
[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
118 const WCHAR sLoadWithoutCOM
[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
119 WCHAR sDllPath
[MAX_PATH
];
122 BOOLEAN bLoadFromShell32
= FALSE
;
123 BOOLEAN bLoadWithoutCOM
= FALSE
;
124 IClassFactory
* pcf
= NULL
;
126 if(!ppv
) return E_POINTER
;
129 /* if the clsid is a string, convert it */
132 if (!aclsid
) return REGDB_E_CLASSNOTREG
;
133 SHCLSIDFromStringW(aclsid
, &iid
);
137 TRACE("(%p,%s,unk:%p,%s,%p)\n",
138 aclsid
,shdebugstr_guid(myclsid
),pUnkOuter
,shdebugstr_guid(refiid
),ppv
);
140 /* we look up the dll path in the registry */
141 __SHGUIDToStringW(myclsid
, sClassID
);
142 lstrcpyW(sKeyName
, sCLSID
);
143 lstrcatW(sKeyName
, sClassID
);
144 lstrcatW(sKeyName
, sInProcServer32
);
146 if (ERROR_SUCCESS
== RegOpenKeyExW(HKEY_CLASSES_ROOT
, sKeyName
, 0, KEY_READ
, &hKey
)) {
147 dwSize
= sizeof(sDllPath
);
148 SHQueryValueExW(hKey
, NULL
, 0,0, sDllPath
, &dwSize
);
150 /* if a special registry key is set, we load a shell extension without help of OLE32 */
151 bLoadWithoutCOM
= (ERROR_SUCCESS
== SHQueryValueExW(hKey
, sLoadWithoutCOM
, 0, 0, 0, 0));
153 /* if the com object is inside shell32, omit use of ole32 */
154 bLoadFromShell32
= (0==lstrcmpiW( PathFindFileNameW(sDllPath
), sShell32
));
158 /* since we can't find it in the registry we try internally */
159 bLoadFromShell32
= TRUE
;
162 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM
, bLoadFromShell32
);
164 /* now we create a instance */
165 if (bLoadFromShell32
) {
166 if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid
, &IID_IClassFactory
,(LPVOID
*)&pcf
))) {
167 ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid
));
169 } else if (bLoadWithoutCOM
) {
171 /* load a external dll without ole32 */
173 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
, REFIID iid
, LPVOID
*ppv
);
174 DllGetClassObjectFunc DllGetClassObject
;
176 if ((hLibrary
= LoadLibraryExW(sDllPath
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
)) == 0) {
177 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath
));
178 hres
= E_ACCESSDENIED
;
180 } else if (!(DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject"))) {
181 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath
));
182 FreeLibrary( hLibrary
);
183 hres
= E_ACCESSDENIED
;
185 } else if (! SUCCEEDED(hres
= DllGetClassObject(myclsid
, &IID_IClassFactory
, (LPVOID
*)&pcf
))) {
186 TRACE("GetClassObject failed 0x%08lx\n", hres
);
192 /* load a external dll in the usual way */
193 hres
= CoCreateInstance(myclsid
, pUnkOuter
, CLSCTX_INPROC_SERVER
, refiid
, ppv
);
197 /* here we should have a ClassFactory */
198 if (!pcf
) return E_ACCESSDENIED
;
200 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
201 IClassFactory_Release(pcf
);
205 ERR("failed (0x%08lx) to create CLSID:%s IID:%s\n",
206 hres
, shdebugstr_guid(myclsid
), shdebugstr_guid(refiid
));
207 ERR("class not found in registry\n");
210 TRACE("-- instance: %p\n",*ppv
);
214 /*************************************************************************
215 * DllGetClassObject [SHELL32.128]
217 HRESULT WINAPI
SHELL32_DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
219 HRESULT hres
= E_OUTOFMEMORY
;
220 IClassFactory
* pcf
= NULL
;
223 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid
),shdebugstr_guid(iid
));
225 if (!ppv
) return E_INVALIDARG
;
228 /* search our internal interface table */
229 for(i
=0;InterfaceTable
[i
].riid
;i
++) {
230 if(IsEqualIID(InterfaceTable
[i
].riid
, rclsid
)) {
231 TRACE("index[%u]\n", i
);
232 pcf
= IDefClF_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
237 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid
));
238 return CLASS_E_CLASSNOTAVAILABLE
;
241 hres
= IClassFactory_QueryInterface(pcf
, iid
, ppv
);
242 IClassFactory_Release(pcf
);
244 TRACE("-- pointer to class factory: %p\n",*ppv
);
248 /*************************************************************************
249 * SHCLSIDFromString [SHELL32.147]
252 * exported by ordinal
254 DWORD WINAPI
SHCLSIDFromStringA (LPCSTR clsid
, CLSID
*id
)
257 TRACE("(%p(%s) %p)\n", clsid
, clsid
, id
);
258 if (!MultiByteToWideChar( CP_ACP
, 0, clsid
, -1, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
259 return CO_E_CLASSSTRING
;
260 return CLSIDFromString( buffer
, id
);
262 DWORD WINAPI
SHCLSIDFromStringW (LPCWSTR clsid
, CLSID
*id
)
264 TRACE("(%p(%s) %p)\n", clsid
, debugstr_w(clsid
), id
);
265 return CLSIDFromString((LPWSTR
)clsid
, id
);
267 DWORD WINAPI
SHCLSIDFromStringAW (LPVOID clsid
, CLSID
*id
)
269 if (SHELL_OsIsUnicode())
270 return SHCLSIDFromStringW (clsid
, id
);
271 return SHCLSIDFromStringA (clsid
, id
);
274 /*************************************************************************
275 * Shell Memory Allocator
278 /* set the vtable later */
279 static IMallocVtbl VT_Shell_IMalloc32
;
281 /* this is the static object instance */
287 static _ShellMalloc Shell_Malloc
= { &VT_Shell_IMalloc32
,1};
289 /* this is the global allocator of shell32 */
290 static IMalloc
* ShellTaskAllocator
= NULL
;
292 /******************************************************************************
293 * IShellMalloc_QueryInterface [VTABLE]
295 static HRESULT WINAPI
IShellMalloc_fnQueryInterface(LPMALLOC iface
, REFIID refiid
, LPVOID
*obj
)
297 TRACE("(%s,%p)\n",shdebugstr_guid(refiid
),obj
);
298 if (IsEqualIID(refiid
, &IID_IUnknown
) || IsEqualIID(refiid
, &IID_IMalloc
)) {
299 *obj
= (LPMALLOC
) &Shell_Malloc
;
302 return E_NOINTERFACE
;
305 /******************************************************************************
306 * IShellMalloc_AddRefRelease [VTABLE]
308 static ULONG WINAPI
IShellMalloc_fnAddRefRelease(LPMALLOC iface
)
313 /******************************************************************************
314 * IShellMalloc_Alloc [VTABLE]
316 static LPVOID WINAPI
IShellMalloc_fnAlloc(LPMALLOC iface
, DWORD cb
)
320 addr
= (LPVOID
) LocalAlloc(GMEM_ZEROINIT
, cb
);
321 TRACE("(%p,%ld);\n",addr
,cb
);
325 /******************************************************************************
326 * IShellMalloc_Realloc [VTABLE]
328 static LPVOID WINAPI
IShellMalloc_fnRealloc(LPMALLOC iface
, LPVOID pv
, DWORD cb
)
334 addr
= (LPVOID
) LocalReAlloc((HANDLE
) pv
, cb
, GMEM_ZEROINIT
| GMEM_MOVEABLE
);
336 LocalFree((HANDLE
) pv
);
341 addr
= (LPVOID
) LocalAlloc(GMEM_ZEROINIT
, cb
);
347 TRACE("(%p->%p,%ld)\n",pv
,addr
,cb
);
351 /******************************************************************************
352 * IShellMalloc_Free [VTABLE]
354 static VOID WINAPI
IShellMalloc_fnFree(LPMALLOC iface
, LPVOID pv
)
357 LocalFree((HANDLE
) pv
);
360 /******************************************************************************
361 * IShellMalloc_GetSize [VTABLE]
363 static DWORD WINAPI
IShellMalloc_fnGetSize(LPMALLOC iface
, LPVOID pv
)
365 DWORD cb
= (DWORD
) LocalSize((HANDLE
)pv
);
366 TRACE("(%p,%ld)\n", pv
, cb
);
370 /******************************************************************************
371 * IShellMalloc_DidAlloc [VTABLE]
373 static INT WINAPI
IShellMalloc_fnDidAlloc(LPMALLOC iface
, LPVOID pv
)
379 /******************************************************************************
380 * IShellMalloc_HeapMinimize [VTABLE]
382 static VOID WINAPI
IShellMalloc_fnHeapMinimize(LPMALLOC iface
)
387 static IMallocVtbl VT_Shell_IMalloc32
=
389 IShellMalloc_fnQueryInterface
,
390 IShellMalloc_fnAddRefRelease
,
391 IShellMalloc_fnAddRefRelease
,
392 IShellMalloc_fnAlloc
,
393 IShellMalloc_fnRealloc
,
395 IShellMalloc_fnGetSize
,
396 IShellMalloc_fnDidAlloc
,
397 IShellMalloc_fnHeapMinimize
400 /*************************************************************************
401 * SHGetMalloc [SHELL32.@]
403 * Return the shell IMalloc interface.
406 * lpmal [O] Destination for IMalloc interface.
409 * Success: S_OK. lpmal contains the shells IMalloc interface.
410 * Failure. An HRESULT error code.
413 * This function will use CoGetMalloc() if OLE32.DLL is already loaded.
414 * If not it uses an internal implementation as a fallback.
416 HRESULT WINAPI
SHGetMalloc(LPMALLOC
*lpmal
)
418 TRACE("(%p)\n", lpmal
);
420 if (!ShellTaskAllocator
)
422 HMODULE hOle32
= GetModuleHandleA("OLE32.DLL");
423 /* this is very suspect. we should not being using a different
424 * allocator from deallocator based on something undeterministic
425 * like whether ole32 is loaded. as it happens currently, they
426 * both map to the same allocator deep down, but this could
427 * change in the future. */
429 CoGetMalloc(MEMCTX_TASK
, &ShellTaskAllocator
);
430 TRACE("got ole32 IMalloc\n");
432 if(!ShellTaskAllocator
) {
433 ShellTaskAllocator
= (IMalloc
* ) &Shell_Malloc
;
434 TRACE("use fallback allocator\n");
437 *lpmal
= ShellTaskAllocator
;
441 /*************************************************************************
442 * SHAlloc [SHELL32.196]
445 * exported by ordinal
447 LPVOID WINAPI
SHAlloc(DWORD len
)
452 if (!ShellTaskAllocator
) SHGetMalloc(&ppv
);
454 ret
= (LPVOID
) IMalloc_Alloc(ShellTaskAllocator
, len
);
455 TRACE("%lu bytes at %p\n",len
, ret
);
459 /*************************************************************************
460 * SHFree [SHELL32.195]
463 * exported by ordinal
465 void WINAPI
SHFree(LPVOID pv
)
470 if (!ShellTaskAllocator
) SHGetMalloc(&ppv
);
471 IMalloc_Free(ShellTaskAllocator
, pv
);
474 /*************************************************************************
475 * SHGetDesktopFolder [SHELL32.@]
477 HRESULT WINAPI
SHGetDesktopFolder(IShellFolder
**psf
)
482 if(!psf
) return E_INVALIDARG
;
484 hres
= ISF_Desktop_Constructor(NULL
, &IID_IShellFolder
,(LPVOID
*)psf
);
486 TRACE("-- %p->(%p)\n",psf
, *psf
);
489 /**************************************************************************
490 * Default ClassFactory Implementation
492 * SHCreateDefClassObject
495 * helper function for dll's without a own classfactory
496 * a generic classfactory is returned
497 * when the CreateInstance of the cf is called the callback is executed
502 IClassFactoryVtbl
*lpVtbl
;
505 LPFNCREATEINSTANCE lpfnCI
;
506 const IID
* riidInst
;
507 ULONG
* pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
510 static IClassFactoryVtbl dclfvt
;
512 /**************************************************************************
513 * IDefClF_fnConstructor
516 IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
)
520 lpclf
= (IDefClFImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl
));
522 lpclf
->lpVtbl
= &dclfvt
;
523 lpclf
->lpfnCI
= lpfnCI
;
524 lpclf
->pcRefDll
= pcRefDll
;
526 if (pcRefDll
) InterlockedIncrement(pcRefDll
);
527 lpclf
->riidInst
= riidInst
;
529 TRACE("(%p)%s\n",lpclf
, shdebugstr_guid(riidInst
));
530 return (LPCLASSFACTORY
)lpclf
;
532 /**************************************************************************
533 * IDefClF_fnQueryInterface
535 static HRESULT WINAPI
IDefClF_fnQueryInterface(
536 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
538 IDefClFImpl
*This
= (IDefClFImpl
*)iface
;
540 TRACE("(%p)->(%s)\n",This
,shdebugstr_guid(riid
));
544 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
)) {
546 InterlockedIncrement(&This
->ref
);
550 TRACE("-- E_NOINTERFACE\n");
551 return E_NOINTERFACE
;
553 /******************************************************************************
556 static ULONG WINAPI
IDefClF_fnAddRef(LPCLASSFACTORY iface
)
558 IDefClFImpl
*This
= (IDefClFImpl
*)iface
;
559 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
561 return InterlockedIncrement(&This
->ref
);
563 /******************************************************************************
566 static ULONG WINAPI
IDefClF_fnRelease(LPCLASSFACTORY iface
)
568 IDefClFImpl
*This
= (IDefClFImpl
*)iface
;
569 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
571 if (!InterlockedDecrement(&This
->ref
))
573 if (This
->pcRefDll
) InterlockedDecrement(This
->pcRefDll
);
575 TRACE("-- destroying IClassFactory(%p)\n",This
);
576 HeapFree(GetProcessHeap(),0,This
);
581 /******************************************************************************
582 * IDefClF_fnCreateInstance
584 static HRESULT WINAPI
IDefClF_fnCreateInstance(
585 LPCLASSFACTORY iface
, LPUNKNOWN pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
587 IDefClFImpl
*This
= (IDefClFImpl
*)iface
;
589 TRACE("%p->(%p,%s,%p)\n",This
,pUnkOuter
,shdebugstr_guid(riid
),ppvObject
);
593 if ( This
->riidInst
==NULL
||
594 IsEqualCLSID(riid
, This
->riidInst
) ||
595 IsEqualCLSID(riid
, &IID_IUnknown
) )
597 return This
->lpfnCI(pUnkOuter
, riid
, ppvObject
);
600 ERR("unknown IID requested %s\n",shdebugstr_guid(riid
));
601 return E_NOINTERFACE
;
603 /******************************************************************************
604 * IDefClF_fnLockServer
606 static HRESULT WINAPI
IDefClF_fnLockServer(LPCLASSFACTORY iface
, BOOL fLock
)
608 IDefClFImpl
*This
= (IDefClFImpl
*)iface
;
609 TRACE("%p->(0x%x), not implemented\n",This
, fLock
);
613 static IClassFactoryVtbl dclfvt
=
615 IDefClF_fnQueryInterface
,
618 IDefClF_fnCreateInstance
,
622 /******************************************************************************
623 * SHCreateDefClassObject [SHELL32.70]
625 HRESULT WINAPI
SHCreateDefClassObject(
628 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
629 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
630 REFIID riidInst
) /* [in] optional interface to the instance */
634 TRACE("%s %p %p %p %s\n",
635 shdebugstr_guid(riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(riidInst
));
637 if (! IsEqualCLSID(riid
, &IID_IClassFactory
) ) return E_NOINTERFACE
;
638 if (! (pcf
= IDefClF_fnConstructor(lpfnCI
, pcRefDll
, riidInst
))) return E_OUTOFMEMORY
;
643 /*************************************************************************
644 * DragAcceptFiles [SHELL32.54]
646 void WINAPI
DragAcceptFiles(HWND hWnd
, BOOL b
)
650 if( !IsWindow(hWnd
) ) return;
651 exstyle
= GetWindowLongA(hWnd
,GWL_EXSTYLE
);
653 exstyle
|= WS_EX_ACCEPTFILES
;
655 exstyle
&= ~WS_EX_ACCEPTFILES
;
656 SetWindowLongA(hWnd
,GWL_EXSTYLE
,exstyle
);
659 /*************************************************************************
660 * DragFinish [SHELL32.80]
662 void WINAPI
DragFinish(HDROP h
)
665 GlobalFree((HGLOBAL
)h
);
668 /*************************************************************************
669 * DragQueryPoint [SHELL32.135]
671 BOOL WINAPI
DragQueryPoint(HDROP hDrop
, POINT
*p
)
673 DROPFILES
*lpDropFileStruct
;
678 lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
680 *p
= lpDropFileStruct
->pt
;
681 bRet
= lpDropFileStruct
->fNC
;
687 /*************************************************************************
688 * DragQueryFile [SHELL32.81]
689 * DragQueryFileA [SHELL32.82]
691 UINT WINAPI
DragQueryFileA(
699 DROPFILES
*lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
701 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszFile
,lLength
);
703 if(!lpDropFileStruct
) goto end
;
705 lpDrop
= (LPSTR
) lpDropFileStruct
+ lpDropFileStruct
->pFiles
;
707 if(lpDropFileStruct
->fWide
== TRUE
) {
708 LPWSTR lpszFileW
= NULL
;
711 lpszFileW
= (LPWSTR
) HeapAlloc(GetProcessHeap(), 0, lLength
*sizeof(WCHAR
));
712 if(lpszFileW
== NULL
) {
716 i
= DragQueryFileW(hDrop
, lFile
, lpszFileW
, lLength
);
719 WideCharToMultiByte(CP_ACP
, 0, lpszFileW
, -1, lpszFile
, lLength
, 0, NULL
);
720 HeapFree(GetProcessHeap(), 0, lpszFileW
);
727 while (*lpDrop
++); /* skip filename */
730 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
737 if (!lpszFile
) goto end
; /* needed buffer size */
738 i
= (lLength
> i
) ? i
: lLength
;
739 lstrcpynA (lpszFile
, lpDrop
, i
);
745 /*************************************************************************
746 * DragQueryFileW [SHELL32.133]
748 UINT WINAPI
DragQueryFileW(
756 DROPFILES
*lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
758 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszwFile
,lLength
);
760 if(!lpDropFileStruct
) goto end
;
762 lpwDrop
= (LPWSTR
) ((LPSTR
)lpDropFileStruct
+ lpDropFileStruct
->pFiles
);
764 if(lpDropFileStruct
->fWide
== FALSE
) {
765 LPSTR lpszFileA
= NULL
;
768 lpszFileA
= (LPSTR
) HeapAlloc(GetProcessHeap(), 0, lLength
);
769 if(lpszFileA
== NULL
) {
773 i
= DragQueryFileA(hDrop
, lFile
, lpszFileA
, lLength
);
776 MultiByteToWideChar(CP_ACP
, 0, lpszFileA
, -1, lpszwFile
, lLength
);
777 HeapFree(GetProcessHeap(), 0, lpszFileA
);
785 while (*lpwDrop
++); /* skip filename */
788 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
793 i
= strlenW(lpwDrop
);
795 if ( !lpszwFile
) goto end
; /* needed buffer size */
797 i
= (lLength
> i
) ? i
: lLength
;
798 lstrcpynW (lpszwFile
, lpwDrop
, i
);