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
38 #include "undocshell.h"
39 #include "wine/unicode.h"
40 #include "shell32_main.h"
42 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
48 extern HRESULT WINAPI
IFSFolder_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
);
50 const WCHAR sShell32
[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
51 const WCHAR sOLE32
[10] = {'O','L','E','3','2','.','D','L','L','\0'};
53 HINSTANCE hShellOle32
= 0;
54 /**************************************************************************
55 * Default ClassFactory types
57 typedef HRESULT (CALLBACK
*LPFNCREATEINSTANCE
)(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppvObject
);
58 IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
);
60 /* this table contains all CLSID's of shell32 objects */
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
},
75 /*************************************************************************
76 * SHCoCreateInstance [SHELL32.102]
82 /* FIXME: this should be SHLWAPI.24 since we can't yet import by ordinal */
84 DWORD WINAPI
__SHGUIDToStringW (REFGUID guid
, LPWSTR str
)
86 WCHAR sFormat
[52] = {'{','%','0','8','l','x','-','%','0','4',
87 'x','-','%','0','4','x','-','%','0','2',
88 'x','%','0','2','x','-','%','0','2','x',
89 '%','0','2','x','%','0','2','x','%','0',
90 '2','x','%','0','2','x','%','0','2','x',
93 return wsprintfW ( str
, sFormat
,
94 guid
->Data1
, guid
->Data2
, guid
->Data3
,
95 guid
->Data4
[0], guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3],
96 guid
->Data4
[4], guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7] );
100 /************************************************************************/
102 LRESULT WINAPI
SHCoCreateInstance(
111 CLSID
* myclsid
= (CLSID
*)clsid
;
112 WCHAR sKeyName
[MAX_PATH
];
113 const WCHAR sCLSID
[7] = {'C','L','S','I','D','\\','\0'};
115 const WCHAR sInProcServer32
[16] ={'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2','\0'};
116 const WCHAR sLoadWithoutCOM
[15] ={'L','o','a','d','W','i','t','h','o','u','t','C','O','M','\0'};
117 WCHAR sDllPath
[MAX_PATH
];
120 BOOLEAN bLoadFromShell32
= FALSE
;
121 BOOLEAN bLoadWithoutCOM
= FALSE
;
122 IClassFactory
* pcf
= NULL
;
124 if(!ppv
) return E_POINTER
;
127 /* if the clsid is a string, convert it */
130 if (!aclsid
) return REGDB_E_CLASSNOTREG
;
131 SHCLSIDFromStringW(aclsid
, &iid
);
135 TRACE("(%p,%s,unk:%p,%s,%p)\n",
136 aclsid
,shdebugstr_guid(myclsid
),pUnkOuter
,shdebugstr_guid(refiid
),ppv
);
138 /* we look up the dll path in the registry */
139 __SHGUIDToStringW(myclsid
, sClassID
);
140 lstrcpyW(sKeyName
, sCLSID
);
141 lstrcatW(sKeyName
, sClassID
);
142 lstrcatW(sKeyName
, sInProcServer32
);
144 if (ERROR_SUCCESS
== RegOpenKeyExW(HKEY_CLASSES_ROOT
, sKeyName
, 0, KEY_READ
, &hKey
)) {
145 dwSize
= sizeof(sDllPath
);
146 SHQueryValueExW(hKey
, NULL
, 0,0, sDllPath
, &dwSize
);
148 /* if a special registry key is set, we load a shell extension without help of OLE32 */
149 bLoadWithoutCOM
= (ERROR_SUCCESS
== SHQueryValueExW(hKey
, sLoadWithoutCOM
, 0, 0, 0, 0));
151 /* if the com object is inside shell32, omit use of ole32 */
152 bLoadFromShell32
= (0==lstrcmpiW( PathFindFileNameW(sDllPath
), sShell32
));
156 /* since we can't find it in the registry we try internally */
157 bLoadFromShell32
= TRUE
;
160 TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM
, bLoadFromShell32
);
162 /* now we create a instance */
163 if (bLoadFromShell32
) {
164 if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid
, &IID_IClassFactory
,(LPVOID
*)&pcf
))) {
165 ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid
));
167 } else if (bLoadWithoutCOM
) {
169 /* load a external dll without ole32 */
171 typedef HRESULT (CALLBACK
*DllGetClassObjectFunc
)(REFCLSID clsid
, REFIID iid
, LPVOID
*ppv
);
172 DllGetClassObjectFunc DllGetClassObject
;
174 if ((hLibrary
= LoadLibraryExW(sDllPath
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
)) == 0) {
175 ERR("couldn't load InprocServer32 dll %s\n", debugstr_w(sDllPath
));
176 hres
= E_ACCESSDENIED
;
178 } else if (!(DllGetClassObject
= (DllGetClassObjectFunc
)GetProcAddress(hLibrary
, "DllGetClassObject"))) {
179 ERR("couldn't find function DllGetClassObject in %s\n", debugstr_w(sDllPath
));
180 FreeLibrary( hLibrary
);
181 hres
= E_ACCESSDENIED
;
183 } else if (! SUCCEEDED(hres
= DllGetClassObject(myclsid
, &IID_IClassFactory
, (LPVOID
*)&pcf
))) {
184 TRACE("GetClassObject failed 0x%08lx\n", hres
);
190 /* load a external dll in the usual way */
191 hres
= CoCreateInstance(myclsid
, pUnkOuter
, CLSCTX_INPROC_SERVER
, refiid
, ppv
);
195 /* here we should have a ClassFactory */
196 if (!pcf
) return E_ACCESSDENIED
;
198 hres
= IClassFactory_CreateInstance(pcf
, pUnkOuter
, refiid
, ppv
);
199 IClassFactory_Release(pcf
);
203 ERR("failed (0x%08lx) to create CLSID:%s IID:%s\n",
204 hres
, shdebugstr_guid(myclsid
), shdebugstr_guid(refiid
));
205 ERR("class not found in registry\n");
208 TRACE("-- instance: %p\n",*ppv
);
212 /*************************************************************************
213 * DllGetClassObject [SHELL32.128]
215 HRESULT WINAPI
SHELL32_DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
217 HRESULT hres
= E_OUTOFMEMORY
;
218 IClassFactory
* pcf
= NULL
;
221 TRACE("CLSID:%s,IID:%s\n",shdebugstr_guid(rclsid
),shdebugstr_guid(iid
));
223 if (!ppv
) return E_INVALIDARG
;
226 /* search our internal interface table */
227 for(i
=0;InterfaceTable
[i
].riid
;i
++) {
228 if(IsEqualIID(InterfaceTable
[i
].riid
, rclsid
)) {
229 TRACE("index[%u]\n", i
);
230 pcf
= IDefClF_fnConstructor(InterfaceTable
[i
].lpfnCI
, NULL
, NULL
);
235 FIXME("failed for CLSID=%s\n", shdebugstr_guid(rclsid
));
236 return CLASS_E_CLASSNOTAVAILABLE
;
239 hres
= IClassFactory_QueryInterface(pcf
, iid
, ppv
);
240 IClassFactory_Release(pcf
);
242 TRACE("-- pointer to class factory: %p\n",*ppv
);
246 /*************************************************************************
247 * SHCLSIDFromString [SHELL32.147]
250 * exported by ordinal
252 DWORD WINAPI
SHCLSIDFromStringA (LPCSTR clsid
, CLSID
*id
)
255 TRACE("(%p(%s) %p)\n", clsid
, clsid
, id
);
256 if (!MultiByteToWideChar( CP_ACP
, 0, clsid
, -1, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
257 return CO_E_CLASSSTRING
;
258 return CLSIDFromString( buffer
, id
);
260 DWORD WINAPI
SHCLSIDFromStringW (LPCWSTR clsid
, CLSID
*id
)
262 TRACE("(%p(%s) %p)\n", clsid
, debugstr_w(clsid
), id
);
263 return CLSIDFromString((LPWSTR
)clsid
, id
);
265 DWORD WINAPI
SHCLSIDFromStringAW (LPVOID clsid
, CLSID
*id
)
267 if (SHELL_OsIsUnicode())
268 return SHCLSIDFromStringW (clsid
, id
);
269 return SHCLSIDFromStringA (clsid
, id
);
272 /*************************************************************************
273 * Shell Memory Allocator
276 /* set the vtable later */
277 static IMallocVtbl VT_Shell_IMalloc32
;
279 /* this is the static object instance */
285 static _ShellMalloc Shell_Malloc
= { &VT_Shell_IMalloc32
,1};
287 /* this is the global allocator of shell32 */
288 static IMalloc
* ShellTaskAllocator
= NULL
;
290 /******************************************************************************
291 * IShellMalloc_QueryInterface [VTABLE]
293 static HRESULT WINAPI
IShellMalloc_fnQueryInterface(LPMALLOC iface
, REFIID refiid
, LPVOID
*obj
)
295 TRACE("(%s,%p)\n",shdebugstr_guid(refiid
),obj
);
296 if (IsEqualIID(refiid
, &IID_IUnknown
) || IsEqualIID(refiid
, &IID_IMalloc
)) {
297 *obj
= (LPMALLOC
) &Shell_Malloc
;
300 return E_NOINTERFACE
;
303 /******************************************************************************
304 * IShellMalloc_AddRefRelease [VTABLE]
306 static ULONG WINAPI
IShellMalloc_fnAddRefRelease(LPMALLOC iface
)
311 /******************************************************************************
312 * IShellMalloc_Alloc [VTABLE]
314 static LPVOID WINAPI
IShellMalloc_fnAlloc(LPMALLOC iface
, DWORD cb
)
318 addr
= (LPVOID
) LocalAlloc(GMEM_ZEROINIT
, cb
);
319 TRACE("(%p,%ld);\n",addr
,cb
);
323 /******************************************************************************
324 * IShellMalloc_Realloc [VTABLE]
326 static LPVOID WINAPI
IShellMalloc_fnRealloc(LPMALLOC iface
, LPVOID pv
, DWORD cb
)
332 addr
= (LPVOID
) LocalReAlloc((HANDLE
) pv
, cb
, GMEM_ZEROINIT
| GMEM_MOVEABLE
);
334 LocalFree((HANDLE
) pv
);
339 addr
= (LPVOID
) LocalAlloc(GMEM_ZEROINIT
, cb
);
345 TRACE("(%p->%p,%ld)\n",pv
,addr
,cb
);
349 /******************************************************************************
350 * IShellMalloc_Free [VTABLE]
352 static VOID WINAPI
IShellMalloc_fnFree(LPMALLOC iface
, LPVOID pv
)
355 LocalFree((HANDLE
) pv
);
358 /******************************************************************************
359 * IShellMalloc_GetSize [VTABLE]
361 static DWORD WINAPI
IShellMalloc_fnGetSize(LPMALLOC iface
, LPVOID pv
)
363 DWORD cb
= (DWORD
) LocalSize((HANDLE
)pv
);
364 TRACE("(%p,%ld)\n", pv
, cb
);
368 /******************************************************************************
369 * IShellMalloc_DidAlloc [VTABLE]
371 static INT WINAPI
IShellMalloc_fnDidAlloc(LPMALLOC iface
, LPVOID pv
)
377 /******************************************************************************
378 * IShellMalloc_HeapMinimize [VTABLE]
380 static VOID WINAPI
IShellMalloc_fnHeapMinimize(LPMALLOC iface
)
385 static IMallocVtbl VT_Shell_IMalloc32
=
387 IShellMalloc_fnQueryInterface
,
388 IShellMalloc_fnAddRefRelease
,
389 IShellMalloc_fnAddRefRelease
,
390 IShellMalloc_fnAlloc
,
391 IShellMalloc_fnRealloc
,
393 IShellMalloc_fnGetSize
,
394 IShellMalloc_fnDidAlloc
,
395 IShellMalloc_fnHeapMinimize
398 /*************************************************************************
399 * SHGetMalloc [SHELL32.@]
401 * Return the shell IMalloc interface.
404 * lpmal [O] Destination for IMalloc interface.
407 * Success: S_OK. lpmal contains the shells IMalloc interface.
408 * Failure. An HRESULT error code.
411 * This function will use CoGetMalloc() if OLE32.DLL is already loaded.
412 * If not it uses an internal implementation as a fallback.
414 HRESULT WINAPI
SHGetMalloc(LPMALLOC
*lpmal
)
416 TRACE("(%p)\n", lpmal
);
418 if (!ShellTaskAllocator
)
420 HMODULE hOle32
= GetModuleHandleA("OLE32.DLL");
421 /* this is very suspect. we should not being using a different
422 * allocator from deallocator based on something undeterministic
423 * like whether ole32 is loaded. as it happens currently, they
424 * both map to the same allocator deep down, but this could
425 * change in the future. */
427 CoGetMalloc(MEMCTX_TASK
, &ShellTaskAllocator
);
428 TRACE("got ole32 IMalloc\n");
430 if(!ShellTaskAllocator
) {
431 ShellTaskAllocator
= (IMalloc
* ) &Shell_Malloc
;
432 TRACE("use fallback allocator\n");
435 *lpmal
= ShellTaskAllocator
;
439 /*************************************************************************
440 * SHAlloc [SHELL32.196]
443 * exported by ordinal
445 LPVOID WINAPI
SHAlloc(DWORD len
)
450 if (!ShellTaskAllocator
) SHGetMalloc(&ppv
);
452 ret
= (LPVOID
) IMalloc_Alloc(ShellTaskAllocator
, len
);
453 TRACE("%lu bytes at %p\n",len
, ret
);
457 /*************************************************************************
458 * SHFree [SHELL32.195]
461 * exported by ordinal
463 void WINAPI
SHFree(LPVOID pv
)
468 if (!ShellTaskAllocator
) SHGetMalloc(&ppv
);
469 IMalloc_Free(ShellTaskAllocator
, pv
);
472 /*************************************************************************
473 * SHGetDesktopFolder [SHELL32.@]
475 HRESULT WINAPI
SHGetDesktopFolder(IShellFolder
**psf
)
480 if(!psf
) return E_INVALIDARG
;
482 hres
= ISF_Desktop_Constructor(NULL
, &IID_IShellFolder
,(LPVOID
*)psf
);
484 TRACE("-- %p->(%p)\n",psf
, *psf
);
487 /**************************************************************************
488 * Default ClassFactory Implementation
490 * SHCreateDefClassObject
493 * helper function for dll's without a own classfactory
494 * a generic classfactory is returned
495 * when the CreateInstance of the cf is called the callback is executed
500 IClassFactoryVtbl
*lpVtbl
;
503 LPFNCREATEINSTANCE lpfnCI
;
504 const IID
* riidInst
;
505 ULONG
* pcRefDll
; /* pointer to refcounter in external dll (ugrrr...) */
508 static IClassFactoryVtbl dclfvt
;
510 /**************************************************************************
511 * IDefClF_fnConstructor
514 IClassFactory
* IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI
, PLONG pcRefDll
, REFIID riidInst
)
518 lpclf
= (IDefClFImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl
));
520 lpclf
->lpVtbl
= &dclfvt
;
521 lpclf
->lpfnCI
= lpfnCI
;
522 lpclf
->pcRefDll
= pcRefDll
;
524 if (pcRefDll
) InterlockedIncrement(pcRefDll
);
525 lpclf
->riidInst
= riidInst
;
527 TRACE("(%p)%s\n",lpclf
, shdebugstr_guid(riidInst
));
528 return (LPCLASSFACTORY
)lpclf
;
530 /**************************************************************************
531 * IDefClF_fnQueryInterface
533 static HRESULT WINAPI
IDefClF_fnQueryInterface(
534 LPCLASSFACTORY iface
, REFIID riid
, LPVOID
*ppvObj
)
536 ICOM_THIS(IDefClFImpl
,iface
);
538 TRACE("(%p)->(%s)\n",This
,shdebugstr_guid(riid
));
542 if(IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IClassFactory
)) {
544 InterlockedIncrement(&This
->ref
);
548 TRACE("-- E_NOINTERFACE\n");
549 return E_NOINTERFACE
;
551 /******************************************************************************
554 static ULONG WINAPI
IDefClF_fnAddRef(LPCLASSFACTORY iface
)
556 ICOM_THIS(IDefClFImpl
,iface
);
557 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
559 return InterlockedIncrement(&This
->ref
);
561 /******************************************************************************
564 static ULONG WINAPI
IDefClF_fnRelease(LPCLASSFACTORY iface
)
566 ICOM_THIS(IDefClFImpl
,iface
);
567 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
569 if (!InterlockedDecrement(&This
->ref
))
571 if (This
->pcRefDll
) InterlockedDecrement(This
->pcRefDll
);
573 TRACE("-- destroying IClassFactory(%p)\n",This
);
574 HeapFree(GetProcessHeap(),0,This
);
579 /******************************************************************************
580 * IDefClF_fnCreateInstance
582 static HRESULT WINAPI
IDefClF_fnCreateInstance(
583 LPCLASSFACTORY iface
, LPUNKNOWN pUnkOuter
, REFIID riid
, LPVOID
*ppvObject
)
585 ICOM_THIS(IDefClFImpl
,iface
);
587 TRACE("%p->(%p,%s,%p)\n",This
,pUnkOuter
,shdebugstr_guid(riid
),ppvObject
);
591 if ( This
->riidInst
==NULL
||
592 IsEqualCLSID(riid
, This
->riidInst
) ||
593 IsEqualCLSID(riid
, &IID_IUnknown
) )
595 return This
->lpfnCI(pUnkOuter
, riid
, ppvObject
);
598 ERR("unknown IID requested %s\n",shdebugstr_guid(riid
));
599 return E_NOINTERFACE
;
601 /******************************************************************************
602 * IDefClF_fnLockServer
604 static HRESULT WINAPI
IDefClF_fnLockServer(LPCLASSFACTORY iface
, BOOL fLock
)
606 ICOM_THIS(IDefClFImpl
,iface
);
607 TRACE("%p->(0x%x), not implemented\n",This
, fLock
);
611 static IClassFactoryVtbl dclfvt
=
613 IDefClF_fnQueryInterface
,
616 IDefClF_fnCreateInstance
,
620 /******************************************************************************
621 * SHCreateDefClassObject [SHELL32.70]
623 HRESULT WINAPI
SHCreateDefClassObject(
626 LPFNCREATEINSTANCE lpfnCI
, /* [in] create instance callback entry */
627 LPDWORD pcRefDll
, /* [in/out] ref count of the dll */
628 REFIID riidInst
) /* [in] optional interface to the instance */
632 TRACE("%s %p %p %p %s\n",
633 shdebugstr_guid(riid
), ppv
, lpfnCI
, pcRefDll
, shdebugstr_guid(riidInst
));
635 if (! IsEqualCLSID(riid
, &IID_IClassFactory
) ) return E_NOINTERFACE
;
636 if (! (pcf
= IDefClF_fnConstructor(lpfnCI
, pcRefDll
, riidInst
))) return E_OUTOFMEMORY
;
641 /*************************************************************************
642 * DragAcceptFiles [SHELL32.54]
644 void WINAPI
DragAcceptFiles(HWND hWnd
, BOOL b
)
648 if( !IsWindow(hWnd
) ) return;
649 exstyle
= GetWindowLongA(hWnd
,GWL_EXSTYLE
);
651 exstyle
|= WS_EX_ACCEPTFILES
;
653 exstyle
&= ~WS_EX_ACCEPTFILES
;
654 SetWindowLongA(hWnd
,GWL_EXSTYLE
,exstyle
);
657 /*************************************************************************
658 * DragFinish [SHELL32.80]
660 void WINAPI
DragFinish(HDROP h
)
663 GlobalFree((HGLOBAL
)h
);
666 /*************************************************************************
667 * DragQueryPoint [SHELL32.135]
669 BOOL WINAPI
DragQueryPoint(HDROP hDrop
, POINT
*p
)
671 DROPFILES
*lpDropFileStruct
;
676 lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
678 *p
= lpDropFileStruct
->pt
;
679 bRet
= lpDropFileStruct
->fNC
;
685 /*************************************************************************
686 * DragQueryFile [SHELL32.81]
687 * DragQueryFileA [SHELL32.82]
689 UINT WINAPI
DragQueryFileA(
697 DROPFILES
*lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
699 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszFile
,lLength
);
701 if(!lpDropFileStruct
) goto end
;
703 lpDrop
= (LPSTR
) lpDropFileStruct
+ lpDropFileStruct
->pFiles
;
705 if(lpDropFileStruct
->fWide
== TRUE
) {
706 LPWSTR lpszFileW
= NULL
;
709 lpszFileW
= (LPWSTR
) HeapAlloc(GetProcessHeap(), 0, lLength
*sizeof(WCHAR
));
710 if(lpszFileW
== NULL
) {
714 i
= DragQueryFileW(hDrop
, lFile
, lpszFileW
, lLength
);
717 WideCharToMultiByte(CP_ACP
, 0, lpszFileW
, -1, lpszFile
, lLength
, 0, NULL
);
718 HeapFree(GetProcessHeap(), 0, lpszFileW
);
725 while (*lpDrop
++); /* skip filename */
728 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
735 if (!lpszFile
) goto end
; /* needed buffer size */
736 i
= (lLength
> i
) ? i
: lLength
;
737 lstrcpynA (lpszFile
, lpDrop
, i
);
743 /*************************************************************************
744 * DragQueryFileW [SHELL32.133]
746 UINT WINAPI
DragQueryFileW(
754 DROPFILES
*lpDropFileStruct
= (DROPFILES
*) GlobalLock(hDrop
);
756 TRACE("(%p, %x, %p, %u)\n", hDrop
,lFile
,lpszwFile
,lLength
);
758 if(!lpDropFileStruct
) goto end
;
760 lpwDrop
= (LPWSTR
) ((LPSTR
)lpDropFileStruct
+ lpDropFileStruct
->pFiles
);
762 if(lpDropFileStruct
->fWide
== FALSE
) {
763 LPSTR lpszFileA
= NULL
;
766 lpszFileA
= (LPSTR
) HeapAlloc(GetProcessHeap(), 0, lLength
);
767 if(lpszFileA
== NULL
) {
771 i
= DragQueryFileA(hDrop
, lFile
, lpszFileA
, lLength
);
774 MultiByteToWideChar(CP_ACP
, 0, lpszFileA
, -1, lpszwFile
, lLength
);
775 HeapFree(GetProcessHeap(), 0, lpszFileA
);
783 while (*lpwDrop
++); /* skip filename */
786 i
= (lFile
== 0xFFFFFFFF) ? i
: 0;
791 i
= strlenW(lpwDrop
);
793 if ( !lpszwFile
) goto end
; /* needed buffer size */
795 i
= (lLength
> i
) ? i
: lLength
;
796 lstrcpynW (lpszwFile
, lpwDrop
, i
);