Sweden-Number/dlls/shell32/shelllink.c

1070 lines
28 KiB
C
Raw Normal View History

/*
*
* Copyright 1997 Marcus Meissner
* Copyright 1998 Juergen Schmied
*
*/
#include <string.h>
#include "debug.h"
#include "winerror.h"
#include "wine/obj_base.h"
#include "wine/obj_storage.h"
1999-02-24 16:58:26 +01:00
#include "wine/obj_shelllink.h"
1999-02-24 16:58:26 +01:00
#include "heap.h"
#include "winnls.h"
#include "pidl.h"
#include "shell32_main.h"
#include "shlguid.h"
1999-02-24 16:58:26 +01:00
/* link file formats */
#pragma (1);
/* lnk elements: simple link has 0x0B */
#define WORKDIR 0x10
#define ARGUMENT 0x20
#define ICON 0x40
/* startup type */
#define NORMAL 0x01
#define MAXIMIZED 0x03
#define MINIMIZED 0x07
typedef struct _LINK_HEADER
{ DWORD MagicStr; /* 0x00 'L','\0','\0','\0' */
GUID MagicGuid; /* 0x04 is CLSID_ShellLink */
DWORD Flag1; /* 0x14 describes elements following */
DWORD Flag2; /* 0x18 */
FILETIME Time1; /* 0x1c */
FILETIME Time2; /* 0x24 */
FILETIME Time3; /* 0x2c */
DWORD Unknown1; /* 0x34 */
DWORD Unknown2; /* 0x38 icon number */
DWORD Flag3; /* 0x3c startup type */
DWORD Unknown4; /* 0x40 hotkey */
DWORD Unknown5; /* 0x44 */
DWORD Unknown6; /* 0x48 */
USHORT PidlSize; /* 0x4c */
ITEMIDLIST Pidl; /* 0x4e */
} LINK_HEADER, * PLINK_HEADER;
#pragma (4);
/* IPersistFile Implementation */
1999-02-17 16:57:24 +01:00
typedef struct
{
1999-02-24 16:58:26 +01:00
/* IUnknown fields */
ICOM_VTABLE(IPersistFile)* lpvtbl;
DWORD ref;
LPSTR sPath;
LPITEMIDLIST pPidl;
1999-02-17 16:57:24 +01:00
} IPersistFileImpl;
static struct ICOM_VTABLE(IPersistFile) pfvt;
/**************************************************************************
* IPersistFile_Constructor
*/
1999-02-24 16:58:26 +01:00
IPersistFileImpl * IPersistFile_Constructor(void)
{
1999-02-17 16:57:24 +01:00
IPersistFileImpl* sl;
1999-02-17 16:57:24 +01:00
sl = (IPersistFileImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IPersistFileImpl));
sl->ref = 1;
sl->lpvtbl = &pfvt;
1999-02-24 16:58:26 +01:00
sl->sPath = NULL;
sl->pPidl = NULL;
TRACE(shell,"(%p)->()\n",sl);
shell32_ObjCount++;
1999-02-24 16:58:26 +01:00
return sl;
}
/**************************************************************************
* IPersistFile_QueryInterface
*/
static HRESULT WINAPI IPersistFile_fnQueryInterface(
IPersistFile* iface, REFIID riid, LPVOID *ppvObj)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IPersistFileImpl,iface);
1999-02-24 16:58:26 +01:00
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
1999-02-17 16:57:24 +01:00
TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
1999-02-17 16:57:24 +01:00
{ *ppvObj = This;
}
else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
1999-02-17 16:57:24 +01:00
{ *ppvObj = (LPPERSISTFILE)This;
}
if(*ppvObj)
{ IPersistFile_AddRef((IPersistFile*)*ppvObj);
TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE(shell,"-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/******************************************************************************
* IPersistFile_AddRef
*/
static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile* iface)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IPersistFileImpl,iface);
1999-02-24 16:58:26 +01:00
1999-02-17 16:57:24 +01:00
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount++;
1999-02-17 16:57:24 +01:00
return ++(This->ref);
}
/******************************************************************************
* IPersistFile_Release
*/
static ULONG WINAPI IPersistFile_fnRelease(IPersistFile* iface)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IPersistFileImpl,iface);
1999-02-24 16:58:26 +01:00
1999-02-17 16:57:24 +01:00
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount--;
1999-02-17 16:57:24 +01:00
if (!--(This->ref))
{ TRACE(shell,"-- destroying IPersistFile(%p)\n",This);
1999-02-24 16:58:26 +01:00
if (This->sPath)
HeapFree(GetProcessHeap(),0,This->sPath);
if (This->pPidl)
SHFree(This->pPidl);
1999-02-17 16:57:24 +01:00
HeapFree(GetProcessHeap(),0,This);
return 0;
}
1999-02-17 16:57:24 +01:00
return This->ref;
}
static HRESULT WINAPI IPersistFile_fnGetClassID(const IPersistFile* iface, CLSID *pClassID)
{
ICOM_CTHIS(IPersistFile,iface);
1999-02-17 16:57:24 +01:00
FIXME(shell,"(%p)\n",This);
return NOERROR;
}
static HRESULT WINAPI IPersistFile_fnIsDirty(const IPersistFile* iface)
{
ICOM_CTHIS(IPersistFile,iface);
1999-02-17 16:57:24 +01:00
FIXME(shell,"(%p)\n",This);
return NOERROR;
}
static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IPersistFileImpl,iface);
1999-02-24 16:58:26 +01:00
OFSTRUCT ofs;
LPSTR sFile = HEAP_strdupWtoA ( GetProcessHeap(), 0, pszFileName);
HFILE hFile = OpenFile( sFile, &ofs, OF_READ );
HANDLE hMapping;
1999-02-24 16:58:26 +01:00
PLINK_HEADER pImage;
HRESULT hRet = E_FAIL;
CHAR sTemp[512];
TRACE(shell,"(%p)->(%s)\n",This,sFile);
HeapFree(GetProcessHeap(),0,sFile);
if ( !(hMapping = CreateFileMappingA(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL)))
1999-02-24 16:58:26 +01:00
{ WARN(shell,"failed to create filemap.\n");
goto end_1;
}
if ( !(pImage = (PLINK_HEADER) MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0)))
{ WARN(shell,"failed to mmap filemap.\n");
goto end_2;
}
if (!( (pImage->MagicStr == 0x0000004CL) && IsEqualIID(&pImage->MagicGuid, &CLSID_ShellLink)))
{ TRACE(shell,"file isn't a lnk\n");
goto end_3;
}
{ /* for debugging */
SYSTEMTIME time;
FileTimeToSystemTime (&pImage->Time1, &time);
GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, sTemp, 256);
1999-02-24 16:58:26 +01:00
TRACE(shell, "-- time1: %s\n", sTemp);
FileTimeToSystemTime (&pImage->Time2, &time);
GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, sTemp, 256);
1999-02-24 16:58:26 +01:00
TRACE(shell, "-- time2: %s\n", sTemp);
FileTimeToSystemTime (&pImage->Time3, &time);
GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, sTemp, 256);
1999-02-24 16:58:26 +01:00
TRACE(shell, "-- time3: %s\n", sTemp);
pdump (&pImage->Pidl);
}
This->pPidl = ILClone (&pImage->Pidl);
_ILGetPidlPath(&pImage->Pidl, sTemp, 512);
This->sPath = HEAP_strdupA ( GetProcessHeap(), 0, sTemp);
hRet = NOERROR;
end_3: UnmapViewOfFile(pImage);
end_2: CloseHandle(hMapping);
end_1: _lclose( hFile);
1999-02-24 16:58:26 +01:00
return hRet;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IPersistFileImpl,iface);
FIXME(shell,"(%p)->(%s)\n",This,debugstr_w(pszFileName));
return NOERROR;
}
static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile* iface, LPCOLESTR pszFileName)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IPersistFileImpl,iface);
FIXME(shell,"(%p)->(%s)\n",This,debugstr_w(pszFileName));
return NOERROR;
}
static HRESULT WINAPI IPersistFile_fnGetCurFile(const IPersistFile* iface, LPOLESTR *ppszFileName)
{
1999-02-17 16:57:24 +01:00
ICOM_CTHIS(IPersistFileImpl,iface);
FIXME(shell,"(%p)\n",This);
return NOERROR;
}
static struct ICOM_VTABLE(IPersistFile) pfvt =
{
1999-02-24 16:58:26 +01:00
IPersistFile_fnQueryInterface,
IPersistFile_fnAddRef,
IPersistFile_fnRelease,
IPersistFile_fnGetClassID,
IPersistFile_fnIsDirty,
IPersistFile_fnLoad,
IPersistFile_fnSave,
IPersistFile_fnSaveCompleted,
IPersistFile_fnGetCurFile
};
/**************************************************************************
* IShellLink's IClassFactory implementation
*/
1999-02-17 16:57:24 +01:00
typedef struct
{
/* IUnknown fields */
ICOM_VTABLE(IClassFactory)* lpvtbl;
DWORD ref;
} IClassFactoryImpl;
static ICOM_VTABLE(IClassFactory) slcfvt;
/**************************************************************************
* IShellLink_CF_Constructor
*/
LPCLASSFACTORY IShellLink_CF_Constructor(void)
{
1999-02-17 16:57:24 +01:00
IClassFactoryImpl* lpclf;
1999-02-17 16:57:24 +01:00
lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
lpclf->ref = 1;
lpclf->lpvtbl = &slcfvt;
TRACE(shell,"(%p)->()\n",lpclf);
shell32_ObjCount++;
return (LPCLASSFACTORY)lpclf;
}
/**************************************************************************
* IShellLink_CF_QueryInterface
*/
static HRESULT WINAPI IShellLink_CF_QueryInterface(
1999-02-17 16:57:24 +01:00
IClassFactory* iface, REFIID riid, LPVOID *ppvObj)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
1999-02-17 16:57:24 +01:00
TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
1999-02-17 16:57:24 +01:00
{ *ppvObj = (LPUNKNOWN)This;
}
else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
1999-02-17 16:57:24 +01:00
{ *ppvObj = (LPCLASSFACTORY)This;
}
if(*ppvObj)
{ IUnknown_AddRef((IUnknown*)*ppvObj);
TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE(shell,"-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/******************************************************************************
* IShellLink_CF_AddRef
*/
1999-02-17 16:57:24 +01:00
static ULONG WINAPI IShellLink_CF_AddRef(IClassFactory* iface)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount++;
1999-02-17 16:57:24 +01:00
return ++(This->ref);
}
/******************************************************************************
* IShellLink_CF_Release
*/
1999-02-17 16:57:24 +01:00
static ULONG WINAPI IShellLink_CF_Release(IClassFactory* iface)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount--;
1999-02-17 16:57:24 +01:00
if (!--(This->ref))
{ TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
HeapFree(GetProcessHeap(),0,This);
return 0;
}
1999-02-17 16:57:24 +01:00
return This->ref;
}
/******************************************************************************
* IShellLink_CF_CreateInstance
*/
static HRESULT WINAPI IShellLink_CF_CreateInstance(
1999-02-17 16:57:24 +01:00
IClassFactory* iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
IUnknown *pObj = NULL;
HRESULT hres;
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
1999-02-17 16:57:24 +01:00
TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
*ppObject = NULL;
if(pUnknown)
{ return(CLASS_E_NOAGGREGATION);
}
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLink))
{ pObj = (IUnknown *)IShellLink_Constructor();
}
else
{ ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
return(E_NOINTERFACE);
}
if (!pObj)
{ return(E_OUTOFMEMORY);
}
hres = IUnknown_QueryInterface(pObj,riid, ppObject);
IUnknown_Release(pObj);
1999-02-17 16:57:24 +01:00
TRACE(shell,"-- Object created: (%p)->%p\n",This,*ppObject);
return hres;
}
/******************************************************************************
* IShellLink_CF_LockServer
*/
static HRESULT WINAPI IShellLink_CF_LockServer(IClassFactory* iface, BOOL fLock)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
TRACE(shell,"%p->(0x%x), not implemented\n",This, fLock);
return E_NOTIMPL;
}
static ICOM_VTABLE(IClassFactory) slcfvt =
{
IShellLink_CF_QueryInterface,
IShellLink_CF_AddRef,
IShellLink_CF_Release,
IShellLink_CF_CreateInstance,
IShellLink_CF_LockServer
};
/**************************************************************************
1999-02-24 16:58:26 +01:00
* IShellLink Implementation
*/
typedef struct
{
ICOM_VTABLE(IShellLink)* lpvtbl;
DWORD ref;
IPersistFileImpl* lppf;
1999-02-24 16:58:26 +01:00
} IShellLinkImpl;
1999-02-24 16:58:26 +01:00
static ICOM_VTABLE(IShellLink) slvt;
/**************************************************************************
* IShellLink_Constructor
*/
1999-02-24 16:58:26 +01:00
IShellLink * IShellLink_Constructor(void)
{ IShellLinkImpl * sl;
1999-02-24 16:58:26 +01:00
sl = (IShellLinkImpl *)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkImpl));
sl->ref = 1;
sl->lpvtbl = &slvt;
sl->lppf = IPersistFile_Constructor();
TRACE(shell,"(%p)->()\n",sl);
shell32_ObjCount++;
1999-02-24 16:58:26 +01:00
return (IShellLink *)sl;
}
/**************************************************************************
* IShellLink::QueryInterface
*/
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnQueryInterface( IShellLink * iface, REFIID riid, LPVOID *ppvObj)
{
ICOM_THIS(IShellLinkImpl, iface);
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
1999-02-24 16:58:26 +01:00
TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
1999-02-24 16:58:26 +01:00
{ *ppvObj = This;
}
else if(IsEqualIID(riid, &IID_IShellLink)) /*IShellLink*/
1999-02-24 16:58:26 +01:00
{ *ppvObj = (IShellLink *)This;
}
else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
1999-02-24 16:58:26 +01:00
{ *ppvObj = (IPersistFile *)This->lppf;
}
if(*ppvObj)
1999-02-24 16:58:26 +01:00
{ IShellLink_AddRef((IShellLink*)*ppvObj);
TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE(shell,"-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/******************************************************************************
* IShellLink_AddRef
*/
1999-02-24 16:58:26 +01:00
static ULONG WINAPI IShellLink_fnAddRef(IShellLink * iface)
{
ICOM_THIS(IShellLinkImpl, iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount++;
1999-02-24 16:58:26 +01:00
return ++(This->ref);
}
/******************************************************************************
* IShellLink_Release
*/
1999-02-24 16:58:26 +01:00
static ULONG WINAPI IShellLink_fnRelease(IShellLink * iface)
{
ICOM_THIS(IShellLinkImpl, iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount--;
1999-02-24 16:58:26 +01:00
if (!--(This->ref))
{ TRACE(shell,"-- destroying IShellLink(%p)\n",This);
IPersistFile_Release((IPersistFile*) This->lppf); /* IPersistFile*/
HeapFree(GetProcessHeap(),0,This);
return 0;
}
1999-02-24 16:58:26 +01:00
return This->ref;
}
static HRESULT WINAPI IShellLink_fnGetPath(IShellLink * iface, LPSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
TRACE(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
strncpy(pszFile,This->lppf->sPath, cchMaxPath);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnGetIDList(IShellLink * iface, LPITEMIDLIST * ppidl)
{
ICOM_THIS(IShellLinkImpl, iface);
TRACE(shell,"(%p)->(ppidl=%p)\n",This, ppidl);
*ppidl = ILClone(This->lppf->pPidl);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnSetIDList(IShellLink * iface, LPCITEMIDLIST pidl)
{
ICOM_THIS(IShellLinkImpl, iface);
TRACE (shell,"(%p)->(pidl=%p)\n",This, pidl);
if (This->lppf->pPidl)
SHFree(This->lppf->pPidl);
This->lppf->pPidl = ILClone (pidl);
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnGetDescription(IShellLink * iface, LPSTR pszName,INT cchMaxName)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
strncpy(pszName,"Description, FIXME",cchMaxName);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnSetDescription(IShellLink * iface, LPCSTR pszName)
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(desc=%s)\n",This, pszName);
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnGetWorkingDirectory(IShellLink * iface, LPSTR pszDir,INT cchMaxPath)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->()\n",This);
strncpy(pszDir,"c:\\", cchMaxPath);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnSetWorkingDirectory(IShellLink * iface, LPCSTR pszDir)
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(dir=%s)\n",This, pszDir);
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnGetArguments(IShellLink * iface, LPSTR pszArgs,INT cchMaxPath)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
strncpy(pszArgs, "", cchMaxPath);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnSetArguments(IShellLink * iface, LPCSTR pszArgs)
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(args=%s)\n",This, pszArgs);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnGetHotkey(IShellLink * iface, WORD *pwHotkey)
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(%p)\n",This, pwHotkey);
*pwHotkey=0x0;
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnSetHotkey(IShellLink * iface, WORD wHotkey)
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnGetShowCmd(IShellLink * iface, INT *piShowCmd)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
*piShowCmd=0;
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnSetShowCmd(IShellLink * iface, INT iShowCmd)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnGetIconLocation(IShellLink * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
strncpy(pszIconPath,"shell32.dll",cchIconPath);
*piIcon=1;
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnSetIconLocation(IShellLink * iface, LPCSTR pszIconPath,INT iIcon)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnSetRelativePath(IShellLink * iface, LPCSTR pszPathRel, DWORD dwReserved)
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
return NOERROR;
}
static HRESULT WINAPI IShellLink_fnResolve(IShellLink * iface, HWND hwnd, DWORD fFlags)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLink_fnSetPath(IShellLink * iface, LPCSTR pszFile)
{
ICOM_THIS(IShellLinkImpl, iface);
FIXME(shell,"(%p)->(path=%s)\n",This, pszFile);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
/**************************************************************************
* IShellLink Implementation
*/
static ICOM_VTABLE(IShellLink) slvt =
{ IShellLink_fnQueryInterface,
IShellLink_fnAddRef,
IShellLink_fnRelease,
IShellLink_fnGetPath,
IShellLink_fnGetIDList,
IShellLink_fnSetIDList,
IShellLink_fnGetDescription,
IShellLink_fnSetDescription,
IShellLink_fnGetWorkingDirectory,
IShellLink_fnSetWorkingDirectory,
IShellLink_fnGetArguments,
IShellLink_fnSetArguments,
IShellLink_fnGetHotkey,
IShellLink_fnSetHotkey,
IShellLink_fnGetShowCmd,
IShellLink_fnSetShowCmd,
IShellLink_fnGetIconLocation,
IShellLink_fnSetIconLocation,
IShellLink_fnSetRelativePath,
IShellLink_fnResolve,
IShellLink_fnSetPath
};
/**************************************************************************
* IShellLink's IClassFactory implementation
*/
static ICOM_VTABLE(IClassFactory) slwcfvt;
/**************************************************************************
* IShellLinkW_CF_Constructor
*/
LPCLASSFACTORY IShellLinkW_CF_Constructor(void)
{
1999-02-17 16:57:24 +01:00
IClassFactoryImpl* lpclf;
1999-02-17 16:57:24 +01:00
lpclf= (IClassFactoryImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IClassFactoryImpl));
lpclf->ref = 1;
lpclf->lpvtbl = &slwcfvt;
TRACE(shell,"(%p)->()\n",lpclf);
shell32_ObjCount++;
return (LPCLASSFACTORY)lpclf;
}
/**************************************************************************
* IShellLinkW_CF_QueryInterface
*/
static HRESULT WINAPI IShellLinkW_CF_QueryInterface(
LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
1999-02-17 16:57:24 +01:00
TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
1999-02-17 16:57:24 +01:00
{ *ppvObj = (LPUNKNOWN)This;
}
else if(IsEqualIID(riid, &IID_IClassFactory)) /*IClassFactory*/
1999-02-17 16:57:24 +01:00
{ *ppvObj = (LPCLASSFACTORY)This;
}
if(*ppvObj) {
IUnknown_AddRef((IUnknown*)*ppvObj);
TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE(shell,"-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/******************************************************************************
* IShellLinkW_CF_AddRef
*/
static ULONG WINAPI IShellLinkW_CF_AddRef(LPCLASSFACTORY iface)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount++;
1999-02-17 16:57:24 +01:00
return ++(This->ref);
}
/******************************************************************************
* IShellLinkW_CF_Release
*/
static ULONG WINAPI IShellLinkW_CF_Release(LPCLASSFACTORY iface)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount--;
1999-02-17 16:57:24 +01:00
if (!--(This->ref))
{ TRACE(shell,"-- destroying IClassFactory(%p)\n",This);
HeapFree(GetProcessHeap(),0,This);
return 0;
}
1999-02-17 16:57:24 +01:00
return This->ref;
}
/******************************************************************************
* IShellLinkW_CF_CreateInstance
*/
static HRESULT WINAPI IShellLinkW_CF_CreateInstance(
LPCLASSFACTORY iface, LPUNKNOWN pUnknown, REFIID riid, LPVOID *ppObject)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
IUnknown *pObj = NULL;
HRESULT hres;
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
1999-02-17 16:57:24 +01:00
TRACE(shell,"%p->(%p,\n\tIID:\t%s,%p)\n",This,pUnknown,xriid,ppObject);
*ppObject = NULL;
if(pUnknown)
{ return(CLASS_E_NOAGGREGATION);
}
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IShellLinkW))
{ pObj = (IUnknown *)IShellLinkW_Constructor();
}
else
{ ERR(shell,"unknown IID requested\n\tIID:\t%s\n",xriid);
return(E_NOINTERFACE);
}
if (!pObj)
{ return(E_OUTOFMEMORY);
}
hres = pObj->lpvtbl->fnQueryInterface(pObj,riid, ppObject);
pObj->lpvtbl->fnRelease(pObj);
1999-02-17 16:57:24 +01:00
TRACE(shell,"-- Object created: (%p)->%p\n",This,*ppObject);
return hres;
}
/******************************************************************************
* IShellLinkW_CF_LockServer
*/
static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY iface, BOOL fLock)
{
1999-02-17 16:57:24 +01:00
ICOM_THIS(IClassFactoryImpl,iface);
TRACE(shell,"%p->(0x%x), not implemented\n",This, fLock);
return E_NOTIMPL;
}
static ICOM_VTABLE(IClassFactory) slwcfvt =
{
IShellLinkW_CF_QueryInterface,
IShellLinkW_CF_AddRef,
IShellLinkW_CF_Release,
IShellLinkW_CF_CreateInstance,
IShellLinkW_CF_LockServer
};
/**************************************************************************
1999-02-24 16:58:26 +01:00
* IShellLink Implementation
*/
1999-02-24 16:58:26 +01:00
typedef struct
{
ICOM_VTABLE(IShellLinkW)* lpvtbl;
DWORD ref;
IPersistFileImpl* lppf;
} IShellLinkWImpl;
static ICOM_VTABLE(IShellLinkW) slvtw;
/**************************************************************************
1999-02-24 16:58:26 +01:00
* IShellLinkW_fnConstructor
*/
1999-02-24 16:58:26 +01:00
IShellLinkW * IShellLinkW_Constructor(void)
{ IShellLinkWImpl* sl;
1999-02-24 16:58:26 +01:00
sl = (IShellLinkWImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IShellLinkWImpl));
sl->ref = 1;
sl->lpvtbl = &slvtw;
sl->lppf = IPersistFile_Constructor();
TRACE(shell,"(%p)->()\n",sl);
shell32_ObjCount++;
1999-02-24 16:58:26 +01:00
return (IShellLinkW*)sl;
}
/**************************************************************************
1999-02-24 16:58:26 +01:00
* IShellLinkW_fnQueryInterface
*/
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnQueryInterface(
IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
{
ICOM_THIS(IShellLinkWImpl, iface);
char xriid[50];
WINE_StringFromCLSID((LPCLSID)riid,xriid);
TRACE(shell,"(%p)->(\n\tIID:\t%s)\n",This,xriid);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
{ *ppvObj = This;
}
else if(IsEqualIID(riid, &IID_IShellLinkW)) /*IShellLinkW*/
{ *ppvObj = (IShellLinkW *)This;
}
else if(IsEqualIID(riid, &IID_IPersistFile)) /*IPersistFile*/
{ *ppvObj = (IPersistFile *)This->lppf;
}
if(*ppvObj)
{ IShellLink_AddRef((IShellLinkW*)*ppvObj);
TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE(shell,"-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/******************************************************************************
1999-02-24 16:58:26 +01:00
* IShellLinkW_fnAddRef
*/
1999-02-24 16:58:26 +01:00
static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
{
ICOM_THIS(IShellLinkWImpl, iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount++;
1999-02-24 16:58:26 +01:00
return ++(This->ref);
}
/******************************************************************************
1999-02-24 16:58:26 +01:00
* IShellLinkW_fnRelease
*/
1999-02-24 16:58:26 +01:00
static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
{
ICOM_THIS(IShellLinkWImpl, iface);
TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
shell32_ObjCount--;
1999-02-24 16:58:26 +01:00
if (!--(This->ref))
{ TRACE(shell,"-- destroying IShellLinkW(%p)\n",This);
IPersistFile_Release((IPersistFile*)This->lppf); /* IPersistFile*/
HeapFree(GetProcessHeap(),0,This);
return 0;
}
1999-02-24 16:58:26 +01:00
return This->ref;
}
static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(pfile=%p len=%u find_data=%p flags=%lu)\n",This, pszFile, cchMaxPath, pfd, fFlags);
lstrcpynAtoW(pszFile,"c:\\foo.bar", cchMaxPath);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(ppidl=%p)\n",This, ppidl);
*ppidl = _ILCreateDesktop();
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(pidl=%p)\n",This, pidl);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
lstrcpynAtoW(pszName,"Description, FIXME",cchMaxName);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(desc=%s)\n",This, debugstr_w(pszName));
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->()\n",This);
lstrcpynAtoW(pszDir,"c:\\", cchMaxPath);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(%p len=%u)\n",This, pszArgs, cchMaxPath);
lstrcpynAtoW(pszArgs, "", cchMaxPath);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR pszArgs)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnGetHotkey(IShellLinkW * iface, WORD *pwHotkey)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(%p)\n",This, pwHotkey);
*pwHotkey=0x0;
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetHotkey(IShellLinkW * iface, WORD wHotkey)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(hotkey=%x)\n",This, wHotkey);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnGetShowCmd(IShellLinkW * iface, INT *piShowCmd)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(%p)\n",This, piShowCmd);
*piShowCmd=0;
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetShowCmd(IShellLinkW * iface, INT iShowCmd)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(showcmd=%x)\n",This, iShowCmd);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(%p len=%u iicon=%p)\n",This, pszIconPath, cchIconPath, piIcon);
lstrcpynAtoW(pszIconPath,"shell32.dll",cchIconPath);
*piIcon=1;
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(path=%s iicon=%u)\n",This, debugstr_w(pszIconPath), iIcon);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetRelativePath(IShellLinkW * iface, LPCWSTR pszPathRel, DWORD dwReserved)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(path=%s %lx)\n",This, debugstr_w(pszPathRel), dwReserved);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnResolve(IShellLinkW * iface, HWND hwnd, DWORD fFlags)
1999-02-24 16:58:26 +01:00
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(hwnd=%x flags=%lx)\n",This, hwnd, fFlags);
return NOERROR;
}
1999-02-24 16:58:26 +01:00
static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile)
{
ICOM_THIS(IShellLinkWImpl, iface);
FIXME(shell,"(%p)->(path=%s)\n",This, debugstr_w(pszFile));
return NOERROR;
}
1999-02-24 16:58:26 +01:00
/**************************************************************************
* IShellLinkW Implementation
*/
static ICOM_VTABLE(IShellLinkW) slvtw =
{ IShellLinkW_fnQueryInterface,
IShellLinkW_fnAddRef,
IShellLinkW_fnRelease,
IShellLinkW_fnGetPath,
IShellLinkW_fnGetIDList,
IShellLinkW_fnSetIDList,
IShellLinkW_fnGetDescription,
IShellLinkW_fnSetDescription,
IShellLinkW_fnGetWorkingDirectory,
IShellLinkW_fnSetWorkingDirectory,
IShellLinkW_fnGetArguments,
IShellLinkW_fnSetArguments,
IShellLinkW_fnGetHotkey,
IShellLinkW_fnSetHotkey,
IShellLinkW_fnGetShowCmd,
IShellLinkW_fnSetShowCmd,
IShellLinkW_fnGetIconLocation,
IShellLinkW_fnSetIconLocation,
IShellLinkW_fnSetRelativePath,
IShellLinkW_fnResolve,
IShellLinkW_fnSetPath
};