#include <stdlib.h>
#include <string.h>
+#define COBJMACROS
+
#include "windef.h"
#include "winbase.h"
#include "shellapi.h"
{&CLSID_DragDropHelper, &IDropTargetHelper_Constructor},
{&CLSID_ControlPanel, &IControlPanel_Constructor},
{&CLSID_AutoComplete, &IAutoComplete_Constructor},
+ {&CLSID_UnixFolder, &UnixFolder_Constructor},
+ {&CLSID_UnixDosFolder, &UnixDosFolder_Constructor},
+ {&CLSID_FolderShortcut, &FolderShortcut_Constructor},
+ {&CLSID_MyDocuments, &MyDocuments_Constructor},
{NULL,NULL}
};
/************************************************************************/
-LRESULT WINAPI SHCoCreateInstance(
+HRESULT WINAPI SHCoCreateInstance(
LPCWSTR aclsid,
const CLSID *clsid,
LPUNKNOWN pUnkOuter,
TRACE("WithoutCom=%u FromShell=%u\n", bLoadWithoutCOM, bLoadFromShell32);
- /* now we create a instance */
+ /* now we create an instance */
if (bLoadFromShell32) {
- if (! SUCCEEDED(SHELL32_DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
+ if (! SUCCEEDED(DllGetClassObject(myclsid, &IID_IClassFactory,(LPVOID*)&pcf))) {
ERR("LoadFromShell failed for CLSID=%s\n", shdebugstr_guid(myclsid));
}
} else if (bLoadWithoutCOM) {
- /* load a external dll without ole32 */
+ /* load an external dll without ole32 */
HANDLE hLibrary;
typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
DllGetClassObjectFunc DllGetClassObject;
} else {
- /* load a external dll in the usual way */
+ /* load an external dll in the usual way */
hres = CoCreateInstance(myclsid, pUnkOuter, CLSCTX_INPROC_SERVER, refiid, ppv);
goto end;
}
}
/*************************************************************************
- * DllGetClassObject [SHELL32.128]
+ * DllGetClassObject [SHELL32.@]
*/
-HRESULT WINAPI SHELL32_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
+HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
{
HRESULT hres = E_OUTOFMEMORY;
IClassFactory * pcf = NULL;
*/
/* set the vtable later */
-extern ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32;
+static const IMallocVtbl VT_Shell_IMalloc32;
/* this is the static object instance */
typedef struct {
- ICOM_VFIELD(IMalloc);
+ const IMallocVtbl *lpVtbl;
DWORD dummy;
} _ShellMalloc;
-_ShellMalloc Shell_Malloc = { &VT_Shell_IMalloc32,1};
+static _ShellMalloc Shell_Malloc = { &VT_Shell_IMalloc32,1};
/* this is the global allocator of shell32 */
-IMalloc * ShellTaskAllocator = NULL;
+static IMalloc * ShellTaskAllocator = NULL;
/******************************************************************************
* IShellMalloc_QueryInterface [VTABLE]
{
LPVOID addr;
- addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
+ addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb);
TRACE("(%p,%ld);\n",addr,cb);
return addr;
}
if (pv) {
if (cb) {
- addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, GMEM_ZEROINIT | GMEM_MOVEABLE);
+ addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, LMEM_ZEROINIT | LMEM_MOVEABLE);
} else {
LocalFree((HANDLE) pv);
addr = NULL;
}
} else {
if (cb) {
- addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb);
+ addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb);
} else {
addr = NULL;
}
TRACE("()\n");
}
-static ICOM_VTABLE(IMalloc) VT_Shell_IMalloc32 =
+static const IMallocVtbl VT_Shell_IMalloc32 =
{
- ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IShellMalloc_fnQueryInterface,
IShellMalloc_fnAddRefRelease,
IShellMalloc_fnAddRefRelease,
/*************************************************************************
* SHGetDesktopFolder [SHELL32.@]
*/
-DWORD WINAPI SHGetDesktopFolder(IShellFolder **psf)
+HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
{
HRESULT hres = S_OK;
TRACE("\n");
* SHCreateDefClassObject
*
* NOTES
- * helper function for dll's without a own classfactory
- * a generic classfactory is returned
- * when the CreateInstance of the cf is called the callback is executed
+ * Helper function for dlls without their own classfactory.
+ * A generic classfactory is returned.
+ * When the CreateInstance of the cf is called the callback is executed.
*/
typedef struct
{
- ICOM_VFIELD(IClassFactory);
- DWORD ref;
+ const IClassFactoryVtbl *lpVtbl;
+ LONG ref;
CLSID *rclsid;
LPFNCREATEINSTANCE lpfnCI;
const IID * riidInst;
- ULONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
+ LONG * pcRefDll; /* pointer to refcounter in external dll (ugrrr...) */
} IDefClFImpl;
-static ICOM_VTABLE(IClassFactory) dclfvt;
+static const IClassFactoryVtbl dclfvt;
/**************************************************************************
* IDefClF_fnConstructor
{
IDefClFImpl* lpclf;
- lpclf = (IDefClFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
+ lpclf = HeapAlloc(GetProcessHeap(),0,sizeof(IDefClFImpl));
lpclf->ref = 1;
lpclf->lpVtbl = &dclfvt;
lpclf->lpfnCI = lpfnCI;
static HRESULT WINAPI IDefClF_fnQueryInterface(
LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
{
- ICOM_THIS(IDefClFImpl,iface);
+ IDefClFImpl *This = (IDefClFImpl *)iface;
TRACE("(%p)->(%s)\n",This,shdebugstr_guid(riid));
*/
static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface)
{
- ICOM_THIS(IDefClFImpl,iface);
- TRACE("(%p)->(count=%lu)\n",This,This->ref);
+ IDefClFImpl *This = (IDefClFImpl *)iface;
+ ULONG refCount = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
- return InterlockedIncrement(&This->ref);
+ return refCount;
}
/******************************************************************************
* IDefClF_fnRelease
*/
static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface)
{
- ICOM_THIS(IDefClFImpl,iface);
- TRACE("(%p)->(count=%lu)\n",This,This->ref);
+ IDefClFImpl *This = (IDefClFImpl *)iface;
+ ULONG refCount = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
- if (!InterlockedDecrement(&This->ref))
+ if (!refCount)
{
if (This->pcRefDll) InterlockedDecrement(This->pcRefDll);
HeapFree(GetProcessHeap(),0,This);
return 0;
}
- return This->ref;
+ return refCount;
}
/******************************************************************************
* IDefClF_fnCreateInstance
static HRESULT WINAPI IDefClF_fnCreateInstance(
LPCLASSFACTORY iface, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject)
{
- ICOM_THIS(IDefClFImpl,iface);
+ IDefClFImpl *This = (IDefClFImpl *)iface;
TRACE("%p->(%p,%s,%p)\n",This,pUnkOuter,shdebugstr_guid(riid),ppvObject);
*/
static HRESULT WINAPI IDefClF_fnLockServer(LPCLASSFACTORY iface, BOOL fLock)
{
- ICOM_THIS(IDefClFImpl,iface);
+ IDefClFImpl *This = (IDefClFImpl *)iface;
TRACE("%p->(0x%x), not implemented\n",This, fLock);
return E_NOTIMPL;
}
-static ICOM_VTABLE(IClassFactory) dclfvt =
+static const IClassFactoryVtbl dclfvt =
{
- ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDefClF_fnQueryInterface,
IDefClF_fnAddRef,
IDefClF_fnRelease,
shdebugstr_guid(riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(riidInst));
if (! IsEqualCLSID(riid, &IID_IClassFactory) ) return E_NOINTERFACE;
- if (! (pcf = IDefClF_fnConstructor(lpfnCI, pcRefDll, riidInst))) return E_OUTOFMEMORY;
+ if (! (pcf = IDefClF_fnConstructor(lpfnCI, (PLONG)pcRefDll, riidInst))) return E_OUTOFMEMORY;
*ppv = pcf;
return NOERROR;
}
/*************************************************************************
- * DragAcceptFiles [SHELL32.54]
+ * DragAcceptFiles [SHELL32.@]
*/
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
{
}
/*************************************************************************
- * DragFinish [SHELL32.80]
+ * DragFinish [SHELL32.@]
*/
void WINAPI DragFinish(HDROP h)
{
}
/*************************************************************************
- * DragQueryPoint [SHELL32.135]
+ * DragQueryPoint [SHELL32.@]
*/
BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
{
}
/*************************************************************************
- * DragQueryFile [SHELL32.81]
- * DragQueryFileA [SHELL32.82]
+ * DragQueryFileA [SHELL32.@]
+ * DragQueryFile [SHELL32.@]
*/
UINT WINAPI DragQueryFileA(
HDROP hDrop,
lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->pFiles;
- if(lpDropFileStruct->fWide == TRUE) {
+ if(lpDropFileStruct->fWide) {
LPWSTR lpszFileW = NULL;
if(lpszFile) {
- lpszFileW = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
+ lpszFileW = HeapAlloc(GetProcessHeap(), 0, lLength*sizeof(WCHAR));
if(lpszFileW == NULL) {
goto end;
}
}
/*************************************************************************
- * DragQueryFileW [SHELL32.133]
+ * DragQueryFileW [SHELL32.@]
*/
UINT WINAPI DragQueryFileW(
HDROP hDrop,
LPSTR lpszFileA = NULL;
if(lpszwFile) {
- lpszFileA = (LPSTR) HeapAlloc(GetProcessHeap(), 0, lLength);
+ lpszFileA = HeapAlloc(GetProcessHeap(), 0, lLength);
if(lpszFileA == NULL) {
goto end;
}