ReactOS  0.4.15-dev-439-g292f67a
CShellLink Class Reference

#include <CShellLink.h>

Inheritance diagram for CShellLink:
Collaboration diagram for CShellLink:

Classes

struct  volume_info
 

Public Types

enum  IDCMD { IDCMD_OPEN = 0, IDCMD_OPENFILELOCATION }
 
- Public Types inherited from IShellLinkA
enum  SLR_FLAGS {
  SLR_NO_UI = 0x0001, SLR_ANY_MATCH = 0x0002, SLR_UPDATE = 0x0004, SLR_NOUPDATE = 0x0008,
  SLR_NOSEARCH = 0x0010, SLR_NOTRACK = 0x0020, SLR_NOLINKINFO = 0x0040, SLR_INVOKE_MSI = 0x0080,
  SLR_NO_UI_WITH_MSG_PUMP = 0x0101
}
 
enum  SLGP_FLAGS { SLGP_SHORTPATH = 0x0001, SLGP_UNCPRIORITY = 0x0002, SLGP_RAWPATH = 0x0004 }
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IPersistStream
typedef IPersistStreamLPPERSISTSTREAM
 
- Public Types inherited from IPersist
typedef IPersistLPPERSIST
 
- Public Types inherited from IPersistFile
typedef IPersistFileLPPERSISTFILE
 
- Public Types inherited from IShellExtInit
typedef IShellExtInitLPSHELLEXTINIT
 
- Public Types inherited from IContextMenu
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IDropTarget
typedef IDropTargetLPDROPTARGET
 
- Public Types inherited from IExtractIconW
typedef IExtractIconWLPEXTRACTICONW
 
- Public Types inherited from IObjectWithSite
typedef IObjectWithSiteLPOBJECTWITHSITE
 
- Public Types inherited from IShellPropSheetExt
enum  tagSHELLPROPSHEETEXTPAGEID { EXPPS_FILETYPES = 0x1 }
 
typedef UINT EXPPS
 

Public Member Functions

 CShellLink ()
 
 ~CShellLink ()
 
BOOL OnInitDialog (HWND hwndDlg, HWND hwndFocus, LPARAM lParam)
 
void OnCommand (HWND hwndDlg, int id, HWND hwndCtl, UINT codeNotify)
 
LRESULT OnNotify (HWND hwndDlg, int idFrom, LPNMHDR pnmhdr)
 
void OnDestroy (HWND hwndDlg)
 
virtual HRESULT STDMETHODCALLTYPE GetClassID (CLSID *pclsid)
 
virtual HRESULT STDMETHODCALLTYPE IsDirty ()
 
virtual HRESULT STDMETHODCALLTYPE Load (LPCOLESTR pszFileName, DWORD dwMode)
 
virtual HRESULT STDMETHODCALLTYPE Save (LPCOLESTR pszFileName, BOOL fRemember)
 
virtual HRESULT STDMETHODCALLTYPE SaveCompleted (LPCOLESTR pszFileName)
 
virtual HRESULT STDMETHODCALLTYPE GetCurFile (LPOLESTR *ppszFileName)
 
virtual HRESULT STDMETHODCALLTYPE Load (IStream *stm)
 
virtual HRESULT STDMETHODCALLTYPE Save (IStream *stm, BOOL fClearDirty)
 
virtual HRESULT STDMETHODCALLTYPE GetSizeMax (ULARGE_INTEGER *pcbSize)
 
virtual HRESULT STDMETHODCALLTYPE GetPath (LPSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags)
 
virtual HRESULT STDMETHODCALLTYPE GetIDList (PIDLIST_ABSOLUTE *ppidl)
 
virtual HRESULT STDMETHODCALLTYPE SetIDList (PCIDLIST_ABSOLUTE pidl)
 
virtual HRESULT STDMETHODCALLTYPE GetDescription (LPSTR pszName, INT cchMaxName)
 
virtual HRESULT STDMETHODCALLTYPE SetDescription (LPCSTR pszName)
 
virtual HRESULT STDMETHODCALLTYPE GetWorkingDirectory (LPSTR pszDir, INT cchMaxPath)
 
virtual HRESULT STDMETHODCALLTYPE SetWorkingDirectory (LPCSTR pszDir)
 
virtual HRESULT STDMETHODCALLTYPE GetArguments (LPSTR pszArgs, INT cchMaxPath)
 
virtual HRESULT STDMETHODCALLTYPE SetArguments (LPCSTR pszArgs)
 
virtual HRESULT STDMETHODCALLTYPE GetHotkey (WORD *pwHotkey)
 
virtual HRESULT STDMETHODCALLTYPE SetHotkey (WORD wHotkey)
 
virtual HRESULT STDMETHODCALLTYPE GetShowCmd (INT *piShowCmd)
 
virtual HRESULT STDMETHODCALLTYPE SetShowCmd (INT iShowCmd)
 
virtual HRESULT STDMETHODCALLTYPE GetIconLocation (LPSTR pszIconPath, INT cchIconPath, INT *piIcon)
 
virtual HRESULT STDMETHODCALLTYPE SetIconLocation (LPCSTR pszIconPath, INT iIcon)
 
virtual HRESULT STDMETHODCALLTYPE SetRelativePath (LPCSTR pszPathRel, DWORD dwReserved)
 
virtual HRESULT STDMETHODCALLTYPE Resolve (HWND hwnd, DWORD fFlags)
 
virtual HRESULT STDMETHODCALLTYPE SetPath (LPCSTR pszFile)
 
virtual HRESULT STDMETHODCALLTYPE GetPath (LPWSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags)
 
virtual HRESULT STDMETHODCALLTYPE GetDescription (LPWSTR pszName, INT cchMaxName)
 
virtual HRESULT STDMETHODCALLTYPE SetDescription (LPCWSTR pszName)
 
virtual HRESULT STDMETHODCALLTYPE GetWorkingDirectory (LPWSTR pszDir, INT cchMaxPath)
 
virtual HRESULT STDMETHODCALLTYPE SetWorkingDirectory (LPCWSTR pszDir)
 
virtual HRESULT STDMETHODCALLTYPE GetArguments (LPWSTR pszArgs, INT cchMaxPath)
 
virtual HRESULT STDMETHODCALLTYPE SetArguments (LPCWSTR pszArgs)
 
virtual HRESULT STDMETHODCALLTYPE GetIconLocation (LPWSTR pszIconPath, INT cchIconPath, INT *piIcon)
 
virtual HRESULT STDMETHODCALLTYPE SetIconLocation (LPCWSTR pszIconPath, INT iIcon)
 
virtual HRESULT STDMETHODCALLTYPE SetRelativePath (LPCWSTR pszPathRel, DWORD dwReserved)
 
virtual HRESULT STDMETHODCALLTYPE SetPath (LPCWSTR pszFile)
 
virtual HRESULT STDMETHODCALLTYPE AddDataBlock (void *pDataBlock)
 
virtual HRESULT STDMETHODCALLTYPE CopyDataBlock (DWORD dwSig, void **ppDataBlock)
 
virtual HRESULT STDMETHODCALLTYPE RemoveDataBlock (DWORD dwSig)
 
virtual HRESULT STDMETHODCALLTYPE GetFlags (DWORD *pdwFlags)
 
virtual HRESULT STDMETHODCALLTYPE SetFlags (DWORD dwFlags)
 
virtual HRESULT STDMETHODCALLTYPE Extract (PCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
 
virtual HRESULT STDMETHODCALLTYPE GetIconLocation (UINT uFlags, PSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
 
virtual HRESULT STDMETHODCALLTYPE Extract (PCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
 
virtual HRESULT STDMETHODCALLTYPE GetIconLocation (UINT uFlags, PWSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
 
virtual HRESULT STDMETHODCALLTYPE Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
 
virtual HRESULT STDMETHODCALLTYPE QueryContextMenu (HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
virtual HRESULT STDMETHODCALLTYPE InvokeCommand (LPCMINVOKECOMMANDINFO lpici)
 
virtual HRESULT STDMETHODCALLTYPE GetCommandString (UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
 
virtual HRESULT STDMETHODCALLTYPE AddPages (LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
 
virtual HRESULT STDMETHODCALLTYPE ReplacePage (UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam)
 
virtual HRESULT STDMETHODCALLTYPE SetSite (IUnknown *punk)
 
virtual HRESULT STDMETHODCALLTYPE GetSite (REFIID iid, void **ppvSite)
 
virtual HRESULT STDMETHODCALLTYPE DragEnter (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
 
virtual HRESULT STDMETHODCALLTYPE DragOver (DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
 
virtual HRESULT STDMETHODCALLTYPE DragLeave ()
 
virtual HRESULT STDMETHODCALLTYPE Drop (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IShellLinkA
HRESULT GetPath ([out, size_is(cch)] LPSTR pszFile, [in] int cch, [in, out, unique] WIN32_FIND_DATAA *pfd, [in] DWORD fFlags)
 
HRESULT GetDescription ([out, size_is(cch)] LPSTR pszName, [in] int cch)
 
HRESULT GetWorkingDirectory ([out, size_is(cch)] LPSTR pszDir, [in] int cch)
 
HRESULT GetArguments ([out, size_is(cch)] LPSTR pszArgs, [in] int cch)
 
HRESULT GetShowCmd ([out] int *piShowCmd)
 
HRESULT SetShowCmd ([in] int iShowCmd)
 
HRESULT GetIconLocation ([out, size_is(cch)] LPSTR pszIconPath, [in] int cch, [out] int *piIcon)
 
HRESULT SetIconLocation ([in] LPCSTR pszIconPath, [in] int iIcon)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- Public Member Functions inherited from IShellLinkW
HRESULT GetPath ([out, size_is(cch)] LPWSTR pszFile, [in] int cch, [in, out] WIN32_FIND_DATAW *pfd, [in] DWORD fFlags)
 
HRESULT GetDescription ([out, size_is(cch)] LPWSTR pszName, [in] int cch)
 
HRESULT GetWorkingDirectory ([out, size_is(cch)] LPWSTR pszDir, [in] int cch)
 
HRESULT GetArguments ([out, size_is(cch)] LPWSTR pszArgs, [in] int cch)
 
HRESULT GetShowCmd ([out] int *piShowCmd)
 
HRESULT SetShowCmd ([in] int iShowCmd)
 
HRESULT GetIconLocation ([out, size_is(cch)] LPWSTR pszIconPath, [in] int cch, [out] int *piIcon)
 
HRESULT SetIconLocation ([in] LPCWSTR pszIconPath, [in] int iIcon)
 
- Public Member Functions inherited from IExtractIconA
HRESULT GetIconLocation ([in] UINT uFlags, [out, size_is(cchMax)] LPSTR szIconFile, [in] UINT cchMax, [out] INT *piIndex, [out] UINT *pwFlags)
 
- Public Member Functions inherited from IExtractIconW
HRESULT GetIconLocation ([in] UINT uFlags, [out, size_is(cchMax)] LPWSTR szIconFile, [in] UINT cchMax, [out] INT *piIndex, [out] UINT *pwFlags)
 
HRESULT Extract ([in] LPCWSTR pszFile, [in] UINT nIconIndex, [out] HICON *phiconLarge, [out] HICON *phiconSmall, [in] UINT nIconSize)
 
- Public Member Functions inherited from IObjectWithSite
HRESULT GetSite ([in] REFIID riid, [out, iid_is(riid)] PVOID *ppvSite)
 
- Public Member Functions inherited from IShellPropSheetExt
HRESULT AddPages ([in] LPFNSVADDPROPSHEETPAGE pfnAddPage, [in] LPARAM lParam)
 
HRESULT ReplacePage ([in] EXPPS uPageID, [in] LPFNSVADDPROPSHEETPAGE pfnReplaceWith, [in] LPARAM lParam)
 

Static Public Member Functions

static INT_PTR CALLBACK SH_ShellLinkDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 

Private Member Functions

VOID Reset ()
 
HRESULT GetAdvertiseInfo (LPWSTR *str, DWORD dwSig)
 
HRESULT SetAdvertiseInfo (LPCWSTR str)
 
HRESULT WriteAdvertiseInfo (LPCWSTR string, DWORD dwSig)
 
HRESULT SetTargetFromPIDLOrPath (LPCITEMIDLIST pidl, LPCWSTR pszFile)
 
HICON CreateShortcutIcon (LPCWSTR wszIconPath, INT IconIndex)
 
HRESULT DoOpen (LPCMINVOKECOMMANDINFO lpici)
 
HRESULT DoOpenFileLocation ()
 

Private Attributes

SHELL_LINK_HEADER m_Header
 
LPITEMIDLIST m_pPidl
 
LPWSTR m_sPath
 
volume_info volume
 
LPWSTR m_sDescription
 
LPWSTR m_sPathRel
 
LPWSTR m_sWorkDir
 
LPWSTR m_sArgs
 
LPWSTR m_sIcoPath
 
BOOL m_bRunAs
 
BOOL m_bDirty
 
LPDBLIST m_pDBList
 
BOOL m_bInInit
 
HICON m_hIcon
 
UINT m_idCmdFirst
 
LPWSTR sProduct
 
LPWSTR sComponent
 
LPWSTR m_sLinkPath
 
CComPtr< IUnknownm_site
 
CComPtr< IDropTargetm_DropTarget
 

Additional Inherited Members

- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Public Attributes inherited from IContextMenu
CMIC_MASK_NOZONECHECKS typedef IContextMenuLPCONTEXTMENU
 
- Public Attributes inherited from IDropTarget
const DWORD MK_ALT = 0x20
 
const DWORD DROPEFFECT_NONE = 0
 
const DWORD DROPEFFECT_COPY = 1
 
const DWORD DROPEFFECT_MOVE = 2
 
const DWORD DROPEFFECT_LINK = 4
 
const DWORD DROPEFFECT_SCROLL = 0x80000000
 
const DWORD DD_DEFSCROLLINSET = 11
 
const DWORD DD_DEFSCROLLDELAY = 50
 
const DWORD DD_DEFSCROLLINTERVAL = 50
 
const DWORD DD_DEFDRAGDELAY = 200
 
const DWORD DD_DEFDRAGMINDIST = 2
 
- Public Attributes inherited from IExtractIconA
GIL_DONTCACHE typedef IExtractIconALPEXTRACTICONA
 
- Static Public Attributes inherited from IContextMenu
static CMDSTR_VIEWDETAILSW(const WCHAR []) const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 28 of file CShellLink.h.

Member Enumeration Documentation

◆ IDCMD

Enumerator
IDCMD_OPEN 
IDCMD_OPENFILELOCATION 

Definition at line 62 of file CShellLink.h.

Constructor & Destructor Documentation

◆ CShellLink()

CShellLink::CShellLink ( )

Definition at line 250 of file CShellLink.cpp.

251 {
252  m_Header.dwSize = sizeof(m_Header);
253  m_Header.clsid = CLSID_ShellLink;
254  m_Header.dwFlags = 0;
255 
261 
262  m_Header.nIconIndex = 0;
264  m_Header.wHotKey = 0;
265 
266  m_pPidl = NULL;
267 
268  m_sPath = NULL;
269  ZeroMemory(&volume, sizeof(volume));
270 
272  m_sPathRel = NULL;
273  m_sWorkDir = NULL;
274  m_sArgs = NULL;
275  m_sIcoPath = NULL;
276  m_bRunAs = FALSE;
277  m_bDirty = FALSE;
278  m_pDBList = NULL;
279  m_bInInit = FALSE;
280  m_hIcon = NULL;
281  m_idCmdFirst = 0;
282 
283  m_sLinkPath = NULL;
284 
286 }
#define ZeroMemory
Definition: winbase.h:1648
smooth NULL
Definition: ftsmooth.c:416
#define SW_SHOWNORMAL
Definition: winuser.h:764

◆ ~CShellLink()

CShellLink::~CShellLink ( )

Definition at line 288 of file CShellLink.cpp.

289 {
290  TRACE("-- destroying IShellLink(%p)\n", this);
291 
292  ILFree(m_pPidl);
293 
295 
303 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList)
Definition: clist.c:331
#define HeapFree(x, y, z)
Definition: compat.h:403

Member Function Documentation

◆ AddDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::AddDataBlock ( void pDataBlock)
virtual

Implements IShellLinkDataList.

Definition at line 2483 of file CShellLink.cpp.

2484 {
2485  if (SHAddDataBlock(&m_pDBList, (DATABLOCK_HEADER*)pDataBlock))
2486  {
2487  m_bDirty = TRUE;
2488  return S_OK;
2489  }
2490  return S_FALSE;
2491 }
#define TRUE
Definition: types.h:120
BOOL WINAPI SHAddDataBlock(LPDBLIST *lppList, const DATABLOCK_HEADER *lpNewItem)
Definition: clist.c:68
#define S_FALSE
Definition: winerror.h:2357
#define S_OK
Definition: intsafe.h:59

Referenced by SetIconLocation(), SetPath(), and WriteAdvertiseInfo().

◆ AddPages()

HRESULT STDMETHODCALLTYPE CShellLink::AddPages ( LPFNADDPROPSHEETPAGE  pfnAddPage,
LPARAM  lParam 
)
virtual

Definition at line 3070 of file CShellLink.cpp.

3071 {
3073  if (hPage == NULL)
3074  {
3075  ERR("failed to create property sheet page\n");
3076  return E_FAIL;
3077  }
3078 
3079  if (!pfnAddPage(hPage, lParam))
3080  return E_FAIL;
3081 
3082  return S_OK;
3083 }
#define E_FAIL
Definition: ddrawi.h:102
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define IDD_SHORTCUT_PROPERTIES
Definition: shresdef.h:341
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
LPARAM lParam
Definition: combotst.c:139

◆ CopyDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::CopyDataBlock ( DWORD  dwSig,
void **  ppDataBlock 
)
virtual

Implements IShellLinkDataList.

Definition at line 2493 of file CShellLink.cpp.

2494 {
2495  DATABLOCK_HEADER* pBlock;
2496  PVOID pDataBlock;
2497 
2498  TRACE("%p %08x %p\n", this, dwSig, ppDataBlock);
2499 
2500  *ppDataBlock = NULL;
2501 
2502  pBlock = SHFindDataBlock(m_pDBList, dwSig);
2503  if (!pBlock)
2504  {
2505  ERR("unknown datablock %08x (not found)\n", dwSig);
2506  return E_FAIL;
2507  }
2508 
2509  pDataBlock = LocalAlloc(LMEM_ZEROINIT, pBlock->cbSize);
2510  if (!pDataBlock)
2511  return E_OUTOFMEMORY;
2512 
2513  CopyMemory(pDataBlock, pBlock, pBlock->cbSize);
2514 
2515  *ppDataBlock = pDataBlock;
2516  return S_OK;
2517 }
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define LMEM_ZEROINIT
Definition: winbase.h:356
#define CopyMemory
Definition: winbase.h:1646
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

◆ CreateShortcutIcon()

HICON CShellLink::CreateShortcutIcon ( LPCWSTR  wszIconPath,
INT  IconIndex 
)
private

Definition at line 3198 of file CShellLink.cpp.

3199 {
3201  const COLORREF crMask = GetSysColor(COLOR_3DFACE);
3202  HDC hDC;
3204  HICON hIcon = NULL, hNewIcon = NULL;
3206  IMAGE_ICON, cx, cy, 0);
3207 
3208  ::ExtractIconExW(wszIconPath, IconIndex, &hIcon, NULL, 1);
3209  if (!hIcon || !hShortcut || !himl)
3210  goto cleanup;
3211 
3213  if (hDC)
3214  {
3215  // create 32bpp bitmap
3216  BITMAPINFO bi;
3217  ZeroMemory(&bi, sizeof(bi));
3218  bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3219  bi.bmiHeader.biWidth = cx;
3220  bi.bmiHeader.biHeight = cy;
3221  bi.bmiHeader.biPlanes = 1;
3222  bi.bmiHeader.biBitCount = 32;
3223  LPVOID pvBits;
3224  HBITMAP hbm = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
3225  if (hbm)
3226  {
3227  // draw the icon image
3228  HGDIOBJ hbmOld = SelectObject(hDC, hbm);
3229  {
3230  HBRUSH hbr = CreateSolidBrush(crMask);
3231  RECT rc = { 0, 0, cx, cy };
3232  FillRect(hDC, &rc, hbr);
3233  DeleteObject(hbr);
3234 
3235  DrawIconEx(hDC, 0, 0, hIcon, cx, cy, 0, NULL, DI_NORMAL);
3236  DrawIconEx(hDC, 0, 0, hShortcut, cx, cy, 0, NULL, DI_NORMAL);
3237  }
3238  SelectObject(hDC, hbmOld);
3239 
3240  INT iAdded = ImageList_AddMasked(himl, hbm, crMask);
3241  hNewIcon = ImageList_GetIcon(himl, iAdded, ILD_NORMAL | ILD_TRANSPARENT);
3242 
3243  DeleteObject(hbm);
3244  }
3245  DeleteDC(hDC);
3246  }
3247 
3248 cleanup:
3249  if (hIcon)
3250  DestroyIcon(hIcon);
3251  if (hShortcut)
3252  DestroyIcon(hShortcut);
3253  if (himl)
3255 
3256  return hNewIcon;
3257 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define IMAGE_ICON
Definition: winuser.h:212
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HIMAGELIST himl
int32_t INT
Definition: typedefs.h:57
DWORD WINAPI GetSysColor(_In_ int)
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
#define ILC_COLOR32
Definition: commctrl.h:354
#define COLOR_3DFACE
Definition: winuser.h:919
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:872
#define SM_CXICON
Definition: winuser.h:962
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
#define IDI_SHELL_SHORTCUT
Definition: shresdef.h:508
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
HICON WINAPI ImageList_GetIcon(HIMAGELIST himl, INT i, UINT fStyle)
Definition: imagelist.c:1963
DWORD COLORREF
Definition: windef.h:300
int WINAPI GetSystemMetrics(_In_ int)
static const WCHAR IconIndex[]
Definition: install.c:52
#define SM_CYICON
Definition: winuser.h:963
#define ILC_MASK
Definition: commctrl.h:347
#define DI_NORMAL
Definition: wingdi.h:72
static HDC hDC
Definition: 3dtext.c:33
#define ILD_TRANSPARENT
Definition: commctrl.h:414
BOOL WINAPI DeleteDC(_In_ HDC)
HICON hIcon
Definition: msconfig.c:44
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
_Out_opt_ int * cx
Definition: commctrl.h:581
char * cleanup(char *str)
Definition: wpickclick.c:99
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
static HBITMAP
Definition: button.c:44
#define ILD_NORMAL
Definition: commctrl.h:413
#define DIB_RGB_COLORS
Definition: wingdi.h:366
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

Referenced by OnCommand().

◆ DoOpen()

HRESULT CShellLink::DoOpen ( LPCMINVOKECOMMANDINFO  lpici)
private

Definition at line 2680 of file CShellLink.cpp.

2681 {
2682  HRESULT hr;
2683  LPWSTR args = NULL;
2685 
2686  if ( lpici->cbSize == sizeof(CMINVOKECOMMANDINFOEX) &&
2687  (lpici->fMask & CMIC_MASK_UNICODE) )
2688  {
2690  SIZE_T len = 2;
2691 
2692  if (m_sArgs)
2693  len += wcslen(m_sArgs);
2694  if (iciex->lpParametersW)
2695  len += wcslen(iciex->lpParametersW);
2696 
2697  args = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2698  *args = 0;
2699  if (m_sArgs)
2700  wcscat(args, m_sArgs);
2701  if (iciex->lpParametersW)
2702  {
2703  wcscat(args, L" ");
2704  wcscat(args, iciex->lpParametersW);
2705  }
2706  }
2707  else if (m_sArgs != NULL)
2708  {
2709  args = strdupW(m_sArgs);
2710  }
2711 
2712  SHELLEXECUTEINFOW sei;
2713  ZeroMemory(&sei, sizeof(sei));
2714  sei.cbSize = sizeof(sei);
2716  (lpici->fMask & (SEE_MASK_NOASYNC | SEE_MASK_ASYNCOK | SEE_MASK_FLAG_NO_UI));
2717  sei.lpFile = path;
2718  sei.lpClass = m_sLinkPath;
2719  sei.nShow = m_Header.nShowCommand;
2720  sei.lpDirectory = m_sWorkDir;
2721  sei.lpParameters = args;
2722  sei.lpVerb = L"open";
2723 
2724  // HACK for ShellExecuteExW
2725  if (m_sPath && wcsstr(m_sPath, L".cpl"))
2726  sei.lpVerb = L"cplopen";
2727 
2728  if (ShellExecuteExW(&sei))
2729  hr = S_OK;
2730  else
2731  hr = E_FAIL;
2732 
2733  HeapFree(GetProcessHeap(), 0, args);
2734  HeapFree(GetProcessHeap(), 0, path);
2735 
2736  return hr;
2737 }
HRESULT hr
Definition: shlfolder.c:183
GLsizei const GLchar ** path
Definition: glext.h:7234
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define SEE_MASK_ASYNCOK
Definition: shellapi.h:52
#define SEE_MASK_HASLINKNAME
Definition: shellapi.h:48
#define ZeroMemory
Definition: winbase.h:1648
#define E_FAIL
Definition: ddrawi.h:102
Definition: match.c:390
LPCWSTR lpDirectory
Definition: shellapi.h:332
smooth NULL
Definition: ftsmooth.c:416
#define SEE_MASK_NOASYNC
Definition: shellapi.h:33
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2263
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
#define SEE_MASK_UNICODE
Definition: shellapi.h:37
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:59
struct IContextMenu::tagCMInvokeCommandInfoEx * LPCMINVOKECOMMANDINFOEX
LPCWSTR lpParameters
Definition: shellapi.h:331
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define args
Definition: format.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by InvokeCommand().

◆ DoOpenFileLocation()

HRESULT CShellLink::DoOpenFileLocation ( )
private

Definition at line 2631 of file CShellLink.cpp.

2632 {
2633  WCHAR szParams[MAX_PATH + 64];
2634  StringCbPrintfW(szParams, sizeof(szParams), L"/select,%s", m_sPath);
2635 
2636  INT_PTR ret;
2637  ret = reinterpret_cast<INT_PTR>(ShellExecuteW(NULL, NULL, L"explorer.exe", szParams,
2639  if (ret <= 32)
2640  {
2641  ERR("ret: %08lX\n", ret);
2642  return E_FAIL;
2643  }
2644 
2645  return S_OK;
2646 }
int32_t INT_PTR
Definition: typedefs.h:63
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274

Referenced by InvokeCommand().

◆ DragEnter()

HRESULT STDMETHODCALLTYPE CShellLink::DragEnter ( IDataObject pDataObject,
DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)
virtual

Implements IDropTarget.

Definition at line 3110 of file CShellLink.cpp.

3112 {
3113  TRACE("(%p)->(DataObject=%p)\n", this, pDataObject);
3114 
3115  if (*pdwEffect == DROPEFFECT_NONE)
3116  return S_OK;
3117 
3118  LPCITEMIDLIST pidlLast;
3120 
3121  HRESULT hr = SHBindToParent(m_pPidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
3122 
3123  if (SUCCEEDED(hr))
3124  {
3125  hr = psf->GetUIObjectOf(0, 1, &pidlLast, IID_NULL_PPV_ARG(IDropTarget, &m_DropTarget));
3126 
3127  if (SUCCEEDED(hr))
3128  hr = m_DropTarget->DragEnter(pDataObject, dwKeyState, pt, pdwEffect);
3129  else
3130  *pdwEffect = DROPEFFECT_NONE;
3131  }
3132  else
3133  *pdwEffect = DROPEFFECT_NONE;
3134 
3135  return S_OK;
3136 }
HRESULT hr
Definition: shlfolder.c:183
#define pt(x, y)
Definition: drawing.c:79
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define IID_PPV_ARG(Itype, ppType)
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
#define IID_NULL_PPV_ARG(Itype, ppType)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1331
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ DragLeave()

HRESULT STDMETHODCALLTYPE CShellLink::DragLeave ( void  )
virtual

Implements IDropTarget.

Definition at line 3148 of file CShellLink.cpp.

3149 {
3150  TRACE("(%p)\n", this);
3151  HRESULT hr = S_OK;
3152  if (m_DropTarget)
3153  {
3154  hr = m_DropTarget->DragLeave();
3156  }
3157 
3158  return hr;
3159 }
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59
void Release()
Definition: atlcomcli.h:140

◆ DragOver()

HRESULT STDMETHODCALLTYPE CShellLink::DragOver ( DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)
virtual

Implements IDropTarget.

Definition at line 3138 of file CShellLink.cpp.

3140 {
3141  TRACE("(%p)\n", this);
3142  HRESULT hr = S_OK;
3143  if (m_DropTarget)
3144  hr = m_DropTarget->DragOver(dwKeyState, pt, pdwEffect);
3145  return hr;
3146 }
HRESULT hr
Definition: shlfolder.c:183
#define pt(x, y)
Definition: drawing.c:79
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59

◆ Drop()

HRESULT STDMETHODCALLTYPE CShellLink::Drop ( IDataObject pDataObject,
DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)
virtual

Implements IDropTarget.

Definition at line 3161 of file CShellLink.cpp.

3163 {
3164  TRACE("(%p)\n", this);
3165  HRESULT hr = S_OK;
3166  if (m_DropTarget)
3167  hr = m_DropTarget->Drop(pDataObject, dwKeyState, pt, pdwEffect);
3168 
3169  return hr;
3170 }
HRESULT hr
Definition: shlfolder.c:183
#define pt(x, y)
Definition: drawing.c:79
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59

◆ Extract() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::Extract ( PCSTR  pszFile,
UINT  nIconIndex,
HICON phiconLarge,
HICON phiconSmall,
UINT  nIconSize 
)
virtual

Implements IExtractIconA.

Definition at line 1311 of file CShellLink.cpp.

1312 {
1313  TRACE("(%p)->(path=%s iicon=%u)\n", this, pszFile, nIconIndex);
1314 
1315  LPWSTR str = NULL;
1316  if (pszFile)
1317  {
1318  str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1319  if (!str)
1320  return E_OUTOFMEMORY;
1321  }
1322 
1323  HRESULT hr = Extract(str, nIconIndex, phiconLarge, phiconSmall, nIconSize);
1324 
1325  if (str)
1326  HeapFree(GetProcessHeap(), 0, str);
1327 
1328  return hr;
1329 }
HRESULT hr
Definition: shlfolder.c:183
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
LONG HRESULT
Definition: typedefs.h:78
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ Extract() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::Extract ( PCWSTR  pszFile,
UINT  nIconIndex,
HICON phiconLarge,
HICON phiconSmall,
UINT  nIconSize 
)
virtual

Definition at line 1753 of file CShellLink.cpp.

1754 {
1755  HRESULT hr = NOERROR;
1756  UINT cxyLarge = LOWORD(nIconSize), cxySmall = HIWORD(nIconSize);
1757 
1758  if (phiconLarge)
1759  {
1760  *phiconLarge = NULL;
1761  PrivateExtractIconsW(pszFile, nIconIndex, cxyLarge, cxyLarge, phiconLarge, NULL, 1, 0);
1762 
1763  if (*phiconLarge == NULL)
1764  hr = S_FALSE;
1765  }
1766 
1767  if (phiconSmall)
1768  {
1769  *phiconSmall = NULL;
1770  PrivateExtractIconsW(pszFile, nIconIndex, cxySmall, cxySmall, phiconSmall, NULL, 1, 0);
1771 
1772  if (*phiconSmall == NULL)
1773  hr = S_FALSE;
1774  }
1775 
1776  if (hr == S_FALSE)
1777  {
1778  if (phiconLarge && *phiconLarge)
1779  {
1780  DestroyIcon(*phiconLarge);
1781  *phiconLarge = NULL;
1782  }
1783  if (phiconSmall && *phiconSmall)
1784  {
1785  DestroyIcon(*phiconSmall);
1786  *phiconSmall = NULL;
1787  }
1788  }
1789 
1790  return hr;
1791 }
HRESULT hr
Definition: shlfolder.c:183
#define NOERROR
Definition: winerror.h:2354
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
UINT WINAPI PrivateExtractIconsW(_In_reads_(MAX_PATH) LPCWSTR szFileName, _In_ int nIconIndex, _In_ int cxIcon, _In_ int cyIcon, _Out_writes_opt_(nIcons) HICON *phicon, _Out_writes_opt_(nIcons) UINT *piconid, _In_ UINT nIcons, _In_ UINT flags)
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:246
#define LOWORD(l)
Definition: pedump.c:82

◆ GetAdvertiseInfo()

HRESULT CShellLink::GetAdvertiseInfo ( LPWSTR str,
DWORD  dwSig 
)
private

Definition at line 605 of file CShellLink.cpp.

606 {
607  LPEXP_DARWIN_LINK pInfo;
608 
609  *str = NULL;
610 
612  if (!pInfo)
613  return E_FAIL;
614 
615  /* Make sure that the size of the structure is valid */
616  if (pInfo->dbh.cbSize != sizeof(*pInfo))
617  {
618  ERR("Ooops. This structure is not as expected...\n");
619  return E_FAIL;
620  }
621 
622  TRACE("dwSig %08x string = '%s'\n", pInfo->dbh.dwSignature, debugstr_w(pInfo->szwDarwinID));
623 
624  *str = pInfo->szwDarwinID;
625  return S_OK;
626 }
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
struct EXP_DARWIN_LINK * LPEXP_DARWIN_LINK
#define TRACE(s)
Definition: solgame.cpp:4
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59

Referenced by Load(), Resolve(), and SetAdvertiseInfo().

◆ GetArguments() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetArguments ( LPSTR  pszArgs,
INT  cchMaxPath 
)
virtual

Definition at line 1195 of file CShellLink.cpp.

1196 {
1197  TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1198 
1199  if (cchMaxPath)
1200  *pszArgs = 0;
1201 
1202  if (m_sArgs)
1204  pszArgs, cchMaxPath, NULL, NULL);
1205 
1206  return S_OK;
1207 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetArguments() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetArguments ( LPWSTR  pszArgs,
INT  cchMaxPath 
)
virtual

Definition at line 1617 of file CShellLink.cpp.

1618 {
1619  TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1620 
1621  if (cchMaxPath)
1622  *pszArgs = 0;
1623 
1624  if (m_sArgs)
1625  lstrcpynW(pszArgs, m_sArgs, cchMaxPath);
1626 
1627  return S_OK;
1628 }
#define lstrcpynW
Definition: compat.h:406
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetClassID()

HRESULT STDMETHODCALLTYPE CShellLink::GetClassID ( CLSID pclsid)
virtual

Implements IPersist.

Definition at line 305 of file CShellLink.cpp.

306 {
307  TRACE("%p %p\n", this, pclsid);
308 
309  if (pclsid == NULL)
310  return E_POINTER;
311  *pclsid = CLSID_ShellLink;
312  return S_OK;
313 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
#define E_POINTER
Definition: winerror.h:2365

◆ GetCommandString()

HRESULT STDMETHODCALLTYPE CShellLink::GetCommandString ( UINT_PTR  idCmd,
UINT  uType,
UINT pwReserved,
LPSTR  pszName,
UINT  cchMax 
)
virtual

Implements IContextMenu.

Definition at line 2739 of file CShellLink.cpp.

2740 {
2741  FIXME("%p %lu %u %p %p %u\n", this, idCmd, uType, pwReserved, pszName, cchMax);
2742  return E_NOTIMPL;
2743 }
#define FIXME(fmt,...)
Definition: debug.h:111
UINT cchMax
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetCurFile()

HRESULT STDMETHODCALLTYPE CShellLink::GetCurFile ( LPOLESTR ppszFileName)
virtual

Implements IPersistFile.

Definition at line 393 of file CShellLink.cpp.

394 {
395  *ppszFileName = NULL;
396 
397  if (!m_sLinkPath)
398  {
399  /* IPersistFile::GetCurFile called before IPersistFile::Save */
400  return S_FALSE;
401  }
402 
403  *ppszFileName = (LPOLESTR)CoTaskMemAlloc((wcslen(m_sLinkPath) + 1) * sizeof(WCHAR));
404  if (!*ppszFileName)
405  {
406  /* out of memory */
407  return E_OUTOFMEMORY;
408  }
409 
410  /* copy last saved filename */
411  wcscpy(*ppszFileName, m_sLinkPath);
412 
413  return S_OK;
414 }
static LPOLESTR
Definition: stg_prop.c:27
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define S_OK
Definition: intsafe.h:59
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ GetDescription() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetDescription ( LPSTR  pszName,
INT  cchMaxName 
)
virtual

Definition at line 1131 of file CShellLink.cpp.

1132 {
1133  TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1134 
1135  if (cchMaxName)
1136  *pszName = 0;
1137 
1138  if (m_sDescription)
1140  pszName, cchMaxName, NULL, NULL);
1141 
1142  return S_OK;
1143 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetDescription() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetDescription ( LPWSTR  pszName,
INT  cchMaxName 
)
virtual

Definition at line 1557 of file CShellLink.cpp.

1558 {
1559  TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1560 
1561  *pszName = 0;
1562  if (m_sDescription)
1563  lstrcpynW(pszName, m_sDescription, cchMaxName);
1564 
1565  return S_OK;
1566 }
#define lstrcpynW
Definition: compat.h:406
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::GetFlags ( DWORD pdwFlags)
virtual

Implements IShellLinkDataList.

Definition at line 2529 of file CShellLink.cpp.

2530 {
2531  TRACE("%p %p\n", this, pdwFlags);
2532  *pdwFlags = m_Header.dwFlags;
2533  return S_OK;
2534 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::GetHotkey ( WORD pwHotkey)
virtual

Implements IShellLinkA.

Definition at line 1227 of file CShellLink.cpp.

1228 {
1229  TRACE("(%p)->(%p)(0x%08x)\n", this, pwHotkey, m_Header.wHotKey);
1230  *pwHotkey = m_Header.wHotKey;
1231  return S_OK;
1232 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetIconLocation() [1/4]

HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation ( LPSTR  pszIconPath,
INT  cchIconPath,
INT piIcon 
)
virtual

Definition at line 1261 of file CShellLink.cpp.

1262 {
1263  HRESULT hr;
1264  LPWSTR pszIconPathW;
1265 
1266  TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1267 
1268  /* Allocate a temporary UNICODE buffer */
1269  pszIconPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchIconPath * sizeof(WCHAR));
1270  if (!pszIconPathW)
1271  return E_OUTOFMEMORY;
1272 
1273  /* Call the UNICODE function */
1274  hr = GetIconLocation(pszIconPathW, cchIconPath, piIcon);
1275 
1276  /* Convert the file path back to ANSI */
1277  WideCharToMultiByte(CP_ACP, 0, pszIconPathW, -1,
1278  pszIconPath, cchIconPath, NULL, NULL);
1279 
1280  /* Free the temporary buffer */
1281  HeapFree(GetProcessHeap(), 0, pszIconPathW);
1282 
1283  return hr;
1284 }
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by GetIconLocation().

◆ GetIconLocation() [2/4]

HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation ( LPWSTR  pszIconPath,
INT  cchIconPath,
INT piIcon 
)
virtual

Definition at line 1648 of file CShellLink.cpp.

1649 {
1650  TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1651 
1652  if (cchIconPath)
1653  *pszIconPath = 0;
1654 
1655  *piIcon = 0;
1656 
1657  /* Update the original icon path location */
1659  {
1661 
1662  /* Search for an icon environment block */
1663  LPEXP_SZ_LINK pInfo;
1665  if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1666  {
1668 
1671 
1673  if (!m_sIcoPath)
1674  return E_OUTOFMEMORY;
1675 
1677 
1678  m_bDirty = TRUE;
1679  }
1680  }
1681 
1682  *piIcon = m_Header.nIconIndex;
1683 
1684  if (m_sIcoPath)
1685  lstrcpynW(pszIconPath, m_sIcoPath, cchIconPath);
1686 
1687  return S_OK;
1688 }
struct EXP_SZ_LINK * LPEXP_SZ_LINK
#define TRUE
Definition: types.h:120
#define EXP_SZ_ICON_SIG
Definition: shlobj.h:1898
#define lstrcpynW
Definition: compat.h:406
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
DWORD WINAPI SHExpandEnvironmentStringsW(LPCWSTR, LPWSTR, DWORD)
#define S_OK
Definition: intsafe.h:59
LPCWSTR szPath
Definition: env.c:35
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ GetIconLocation() [3/4]

HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation ( UINT  uFlags,
PSTR  pszIconFile,
UINT  cchMax,
int piIndex,
UINT pwFlags 
)
virtual

Definition at line 1286 of file CShellLink.cpp.

1287 {
1288  HRESULT hr;
1289  LPWSTR pszIconFileW;
1290 
1291  TRACE("(%p)->(%u %p len=%u piIndex=%p pwFlags=%p)\n", this, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1292 
1293  /* Allocate a temporary UNICODE buffer */
1294  pszIconFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR));
1295  if (!pszIconFileW)
1296  return E_OUTOFMEMORY;
1297 
1298  /* Call the UNICODE function */
1299  hr = GetIconLocation(uFlags, pszIconFileW, cchMax, piIndex, pwFlags);
1300 
1301  /* Convert the file path back to ANSI */
1302  WideCharToMultiByte(CP_ACP, 0, pszIconFileW, -1,
1303  pszIconFile, cchMax, NULL, NULL);
1304 
1305  /* Free the temporary buffer */
1306  HeapFree(GetProcessHeap(), 0, pszIconFileW);
1307 
1308  return hr;
1309 }
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
UINT uFlags
Definition: api.c:59
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
UINT cchMax
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ GetIconLocation() [4/4]

HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation ( UINT  uFlags,
PWSTR  pszIconFile,
UINT  cchMax,
int piIndex,
UINT pwFlags 
)
virtual

Definition at line 1712 of file CShellLink.cpp.

1713 {
1714  HRESULT hr;
1715 
1716  pszIconFile[0] = UNICODE_NULL;
1717 
1718  /*
1719  * It is possible for a shell link to point to another shell link,
1720  * and in particular there is the possibility to point to itself.
1721  * Now, suppose we ask such a link to retrieve its associated icon.
1722  * This function would be called, and due to COM would be called again
1723  * recursively. To solve this issue, we forbid calling GetIconLocation()
1724  * with GIL_FORSHORTCUT set in uFlags, as done by Windows (shown by tests).
1725  */
1726  if (uFlags & GIL_FORSHORTCUT)
1727  return E_INVALIDARG;
1728 
1729  /*
1730  * Now, we set GIL_FORSHORTCUT so that: i) we allow the icon extractor
1731  * of the target to give us a suited icon, and ii) we protect ourselves
1732  * against recursive call.
1733  */
1734  uFlags |= GIL_FORSHORTCUT;
1735 
1736  if (uFlags & GIL_DEFAULTICON)
1737  return S_FALSE;
1738 
1739  hr = GetIconLocation(pszIconFile, cchMax, piIndex);
1740  if (FAILED(hr) || pszIconFile[0] == UNICODE_NULL)
1741  {
1742  hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1743  }
1744  else
1745  {
1746  *pwFlags = GIL_NOTFILENAME | GIL_PERCLASS;
1747  }
1748 
1749  return hr;
1750 }
HRESULT hr
Definition: shlfolder.c:183
UINT uFlags
Definition: api.c:59
#define UNICODE_NULL
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG HRESULT
Definition: typedefs.h:78
UINT cchMax

◆ GetIDList()

HRESULT STDMETHODCALLTYPE CShellLink::GetIDList ( PIDLIST_ABSOLUTE ppidl)
virtual

Implements IShellLinkA.

Definition at line 1111 of file CShellLink.cpp.

1112 {
1113  TRACE("(%p)->(ppidl=%p)\n", this, ppidl);
1114 
1115  if (!m_pPidl)
1116  {
1117  *ppidl = NULL;
1118  return S_FALSE;
1119  }
1120 
1121  *ppidl = ILClone(m_pPidl);
1122  return S_OK;
1123 }
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228

◆ GetPath() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetPath ( LPSTR  pszFile,
INT  cchMaxPath,
WIN32_FIND_DATAA pfd,
DWORD  fFlags 
)
virtual

Definition at line 1062 of file CShellLink.cpp.

1063 {
1064  HRESULT hr;
1065  LPWSTR pszFileW;
1066  WIN32_FIND_DATAW wfd;
1067 
1068  TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1069  this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1070 
1071  /* Allocate a temporary UNICODE buffer */
1072  pszFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchMaxPath * sizeof(WCHAR));
1073  if (!pszFileW)
1074  return E_OUTOFMEMORY;
1075 
1076  /* Call the UNICODE function */
1077  hr = GetPath(pszFileW, cchMaxPath, &wfd, fFlags);
1078 
1079  /* Convert the file path back to ANSI */
1080  WideCharToMultiByte(CP_ACP, 0, pszFileW, -1,
1081  pszFile, cchMaxPath, NULL, NULL);
1082 
1083  /* Free the temporary buffer */
1084  HeapFree(GetProcessHeap(), 0, pszFileW);
1085 
1086  if (pfd)
1087  {
1088  ZeroMemory(pfd, sizeof(*pfd));
1089 
1090  /* Copy the file data if a file path was returned */
1091  if (*pszFile)
1092  {
1093  DWORD len;
1094 
1095  /* Copy the fixed part */
1096  CopyMemory(pfd, &wfd, FIELD_OFFSET(WIN32_FIND_DATAA, cFileName));
1097 
1098  /* Convert the file names to ANSI */
1099  len = lstrlenW(wfd.cFileName);
1100  WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, len + 1,
1101  pfd->cFileName, sizeof(pfd->cFileName), NULL, NULL);
1102  len = lstrlenW(wfd.cAlternateFileName);
1103  WideCharToMultiByte(CP_ACP, 0, wfd.cAlternateFileName, len + 1,
1104  pfd->cAlternateFileName, sizeof(pfd->cAlternateFileName), NULL, NULL);
1105  }
1106  }
1107 
1108  return hr;
1109 }
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define CP_ACP
Definition: compat.h:99
#define ZeroMemory
Definition: winbase.h:1648
#define lstrlenW
Definition: compat.h:416
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define CopyMemory
Definition: winbase.h:1646
unsigned long DWORD
Definition: ntddk_ex.h:95
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
GLenum GLsizei len
Definition: glext.h:6722
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ GetPath() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetPath ( LPWSTR  pszFile,
INT  cchMaxPath,
WIN32_FIND_DATAW pfd,
DWORD  fFlags 
)
virtual

Definition at line 1476 of file CShellLink.cpp.

1477 {
1479 
1480  TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1481  this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1482 
1483  if (cchMaxPath)
1484  *pszFile = 0;
1485  // FIXME: What if cchMaxPath == 0 , or pszFile == NULL ??
1486 
1487  // FIXME: What about Darwin??
1488 
1489  /*
1490  * Retrieve the path to the target from the PIDL (if we have one).
1491  * NOTE: Do NOT use the cached path (m_sPath from link info).
1492  */
1494  {
1495  if (fFlags & SLGP_SHORTPATH)
1497  // FIXME: Add support for SLGP_UNCPRIORITY
1498  }
1499  else
1500  {
1501  *buffer = 0;
1502  }
1503 
1504  /* If we have a FindData structure, initialize it */
1505  if (pfd)
1506  {
1507  ZeroMemory(pfd, sizeof(*pfd));
1508 
1509  /* Copy the file data if the target is a file path */
1510  if (*buffer)
1511  {
1512  pfd->dwFileAttributes = m_Header.dwFileAttributes;
1513  pfd->ftCreationTime = m_Header.ftCreationTime;
1514  pfd->ftLastAccessTime = m_Header.ftLastAccessTime;
1515  pfd->ftLastWriteTime = m_Header.ftLastWriteTime;
1516  pfd->nFileSizeHigh = 0;
1517  pfd->nFileSizeLow = m_Header.nFileSizeLow;
1518 
1519  /*
1520  * Build temporarily a short path in pfd->cFileName (of size MAX_PATH),
1521  * then extract and store the short file name in pfd->cAlternateFileName.
1522  */
1523  GetShortPathNameW(buffer, pfd->cFileName, _countof(pfd->cFileName));
1524  lstrcpynW(pfd->cAlternateFileName,
1525  PathFindFileNameW(pfd->cFileName),
1526  _countof(pfd->cAlternateFileName));
1527 
1528  /* Now extract and store the long file name in pfd->cFileName */
1529  lstrcpynW(pfd->cFileName,
1531  _countof(pfd->cFileName));
1532  }
1533  }
1534 
1535  /* Finally check if we have a raw path the user actually wants to retrieve */
1536  if ((fFlags & SLGP_RAWPATH) && (m_Header.dwFlags & SLDF_HAS_EXP_SZ))
1537  {
1538  /* Search for a target environment block */
1539  LPEXP_SZ_LINK pInfo;
1541  if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1542  lstrcpynW(buffer, pInfo->szwTarget, cchMaxPath);
1543  }
1544 
1545  /* For diagnostics purposes only... */
1546  // NOTE: SLGP_UNCPRIORITY is unsupported
1547  fFlags &= ~(SLGP_RAWPATH | SLGP_SHORTPATH);
1548  if (fFlags) FIXME("(%p): Unsupported flags %lu\n", this, fFlags);
1549 
1550  /* Copy the data back to the user */
1551  if (*buffer)
1552  lstrcpynW(pszFile, buffer, cchMaxPath);
1553 
1554  return (*buffer ? S_OK : S_FALSE);
1555 }
struct EXP_SZ_LINK * LPEXP_SZ_LINK
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1288
#define ZeroMemory
Definition: winbase.h:1648
GLuint buffer
Definition: glext.h:5915
#define lstrcpynW
Definition: compat.h:406
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define S_FALSE
Definition: winerror.h:2357
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1832
#define MAX_PATH
Definition: compat.h:26
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
#define S_OK
Definition: intsafe.h:59
#define EXP_SZ_LINK_SIG
Definition: shlobj.h:1890

◆ GetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::GetShowCmd ( INT piShowCmd)
virtual

Definition at line 1244 of file CShellLink.cpp.

1245 {
1246  TRACE("(%p)->(%p) %d\n", this, piShowCmd, m_Header.nShowCommand);
1247  *piShowCmd = m_Header.nShowCommand;
1248  return S_OK;
1249 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetSite()

HRESULT STDMETHODCALLTYPE CShellLink::GetSite ( REFIID  iid,
void **  ppvSite 
)
virtual

Definition at line 3100 of file CShellLink.cpp.

3101 {
3102  TRACE("%p %s %p\n", this, debugstr_guid(&iid), ppvSite);
3103 
3104  if (m_site == NULL)
3105  return E_FAIL;
3106 
3107  return m_site->QueryInterface(iid, ppvSite);
3108 }
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4

◆ GetSizeMax()

HRESULT STDMETHODCALLTYPE CShellLink::GetSizeMax ( ULARGE_INTEGER pcbSize)
virtual

Implements IPersistStream.

Definition at line 994 of file CShellLink.cpp.

995 {
996  TRACE("(%p)\n", this);
997  return E_NOTIMPL;
998 }
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetWorkingDirectory() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetWorkingDirectory ( LPSTR  pszDir,
INT  cchMaxPath 
)
virtual

Definition at line 1163 of file CShellLink.cpp.

1164 {
1165  TRACE("(%p)->(%p len=%u)\n", this, pszDir, cchMaxPath);
1166 
1167  if (cchMaxPath)
1168  *pszDir = 0;
1169 
1170  if (m_sWorkDir)
1172  pszDir, cchMaxPath, NULL, NULL);
1173 
1174  return S_OK;
1175 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_In_ LPCSTR pszDir
Definition: shellapi.h:580
#define S_OK
Definition: intsafe.h:59

◆ GetWorkingDirectory() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::GetWorkingDirectory ( LPWSTR  pszDir,
INT  cchMaxPath 
)
virtual

Definition at line 1586 of file CShellLink.cpp.

1587 {
1588  TRACE("(%p)->(%p len %u)\n", this, pszDir, cchMaxPath);
1589 
1590  if (cchMaxPath)
1591  *pszDir = 0;
1592 
1593  if (m_sWorkDir)
1594  lstrcpynW(pszDir, m_sWorkDir, cchMaxPath);
1595 
1596  return S_OK;
1597 }
#define lstrcpynW
Definition: compat.h:406
#define TRACE(s)
Definition: solgame.cpp:4
_In_ LPCSTR pszDir
Definition: shellapi.h:580
#define S_OK
Definition: intsafe.h:59

◆ Initialize()

HRESULT STDMETHODCALLTYPE CShellLink::Initialize ( PCIDLIST_ABSOLUTE  pidlFolder,
IDataObject pdtobj,
HKEY  hkeyProgID 
)
virtual

Implements IShellExtInit.

Definition at line 2553 of file CShellLink.cpp.

2554 {
2555  TRACE("%p %p %p %p\n", this, pidlFolder, pdtobj, hkeyProgID);
2556 
2557  if (!pdtobj)
2558  return E_FAIL;
2559 
2560  FORMATETC format;
2561  format.cfFormat = CF_HDROP;
2562  format.ptd = NULL;
2563  format.dwAspect = DVASPECT_CONTENT;
2564  format.lindex = -1;
2565  format.tymed = TYMED_HGLOBAL;
2566 
2567  STGMEDIUM stgm;
2568  HRESULT hr = pdtobj->GetData(&format, &stgm);
2569  if (FAILED(hr))
2570  return hr;
2571 
2572  UINT count = DragQueryFileW((HDROP)stgm.hGlobal, -1, NULL, 0);
2573  if (count == 1)
2574  {
2575  count = DragQueryFileW((HDROP)stgm.hGlobal, 0, NULL, 0);
2576  count++;
2577  LPWSTR path = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
2578  if (path)
2579  {
2580  count = DragQueryFileW((HDROP)stgm.hGlobal, 0, path, count);
2581  hr = Load(path, 0);
2582  HeapFree(GetProcessHeap(), 0, path);
2583  }
2584  }
2585  ReleaseStgMedium(&stgm);
2586 
2587  return S_OK;
2588 }
HRESULT hr
Definition: shlfolder.c:183
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
GLuint GLuint GLsizei count
Definition: gl.h:1545
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define E_FAIL
Definition: ddrawi.h:102
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
#define CF_HDROP
Definition: constants.h:410
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:627
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ InvokeCommand()

HRESULT STDMETHODCALLTYPE CShellLink::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
virtual

Implements IContextMenu.

Definition at line 2648 of file CShellLink.cpp.

2649 {
2650  TRACE("%p %p\n", this, lpici);
2651 
2652  if (lpici->cbSize < sizeof(CMINVOKECOMMANDINFO))
2653  return E_INVALIDARG;
2654 
2655  // NOTE: We could use lpici->hwnd (certainly in case lpici->fMask doesn't contain CMIC_MASK_FLAG_NO_UI)
2656  // as the parent window handle... ?
2657  /* FIXME: get using interface set from IObjectWithSite?? */
2658  // NOTE: We might need an extended version of Resolve that provides us with paths...
2659  HRESULT hr = Resolve(lpici->hwnd, 0);
2660  if (FAILED(hr))
2661  {
2662  TRACE("failed to resolve component with error 0x%08x", hr);
2663  return hr;
2664  }
2665 
2666  UINT idCmd = LOWORD(lpici->lpVerb);
2667  TRACE("idCmd: %d\n", idCmd);
2668 
2669  switch (idCmd)
2670  {
2671  case IDCMD_OPEN:
2672  return DoOpen(lpici);
2674  return DoOpenFileLocation();
2675  default:
2676  return E_NOTIMPL;
2677  }
2678 }
HRESULT hr
Definition: shlfolder.c:183
struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82

◆ IsDirty()

HRESULT STDMETHODCALLTYPE CShellLink::IsDirty ( void  )
virtual

Implements IPersistStream.

Definition at line 318 of file CShellLink.cpp.

319 {
320  TRACE("(%p)\n", this);
321  return (m_bDirty ? S_OK : S_FALSE);
322 }
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ Load() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::Load ( LPCOLESTR  pszFileName,
DWORD  dwMode 
)
virtual

Implements IPersistFile.

Definition at line 324 of file CShellLink.cpp.

325 {
326  TRACE("(%p, %s, %x)\n", this, debugstr_w(pszFileName), dwMode);
327 
328  if (dwMode == 0)
329  dwMode = STGM_READ | STGM_SHARE_DENY_WRITE;
330 
331  CComPtr<IStream> stm;
332  HRESULT hr = SHCreateStreamOnFileW(pszFileName, dwMode, &stm);
333  if (SUCCEEDED(hr))
334  {
337  hr = Load(stm);
339  m_bDirty = FALSE;
340  }
341  TRACE("-- returning hr %08x\n", hr);
342  return hr;
343 }
HRESULT hr
Definition: shlfolder.c:183
#define debugstr_w
Definition: kernel32.h:32
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
#define STGM_READ
Definition: objbase.h:916
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
LONG HRESULT
Definition: typedefs.h:78
HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
Definition: istream.c:484
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:921
#define HeapFree(x, y, z)
Definition: compat.h:403
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by Initialize().

◆ Load() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::Load ( IStream stm)
virtual

Implements IPersistStream.

Definition at line 631 of file CShellLink.cpp.

632 {
633  TRACE("%p %p\n", this, stm);
634 
635  if (!stm)
636  return STG_E_INVALIDPOINTER;
637 
638  /* Free all the old stuff */
639  Reset();
640 
641  ULONG dwBytesRead = 0;
642  HRESULT hr = stm->Read(&m_Header, sizeof(m_Header), &dwBytesRead);
643  if (FAILED(hr))
644  return hr;
645 
646  if (dwBytesRead != sizeof(m_Header))
647  return E_FAIL;
648  if (m_Header.dwSize != sizeof(m_Header))
649  return E_FAIL;
650  if (!IsEqualIID(m_Header.clsid, CLSID_ShellLink))
651  return E_FAIL;
652 
653  /* Load the new data in order */
654 
655  if (TRACE_ON(shell))
656  {
657  SYSTEMTIME stCreationTime;
658  SYSTEMTIME stLastAccessTime;
659  SYSTEMTIME stLastWriteTime;
660  WCHAR sTemp[MAX_PATH];
661 
662  FileTimeToSystemTime(&m_Header.ftCreationTime, &stCreationTime);
663  FileTimeToSystemTime(&m_Header.ftLastAccessTime, &stLastAccessTime);
664  FileTimeToSystemTime(&m_Header.ftLastWriteTime, &stLastWriteTime);
665 
667  NULL, sTemp, _countof(sTemp));
668  TRACE("-- stCreationTime: %s\n", debugstr_w(sTemp));
670  NULL, sTemp, _countof(sTemp));
671  TRACE("-- stLastAccessTime: %s\n", debugstr_w(sTemp));
673  NULL, sTemp, _countof(sTemp));
674  TRACE("-- stLastWriteTime: %s\n", debugstr_w(sTemp));
675  }
676 
677  /* load all the new stuff */
679  {
680  hr = ILLoadFromStream(stm, &m_pPidl);
681  if (FAILED(hr))
682  return hr;
683  }
684  pdump(m_pPidl);
685 
686  /* Load the location information... */
688  {
690  if (FAILED(hr))
691  return hr;
692  }
693  /* ... but if it is required not to use it, clear it */
695  {
697  m_sPath = NULL;
698  ZeroMemory(&volume, sizeof(volume));
699  }
700 
701  BOOL unicode = !!(m_Header.dwFlags & SLDF_UNICODE);
702 
704  {
705  hr = Stream_LoadString(stm, unicode, &m_sDescription);
706  if (FAILED(hr))
707  return hr;
708  TRACE("Description -> %s\n", debugstr_w(m_sDescription));
709  }
710 
712  {
713  hr = Stream_LoadString(stm, unicode, &m_sPathRel);
714  if (FAILED(hr))
715  return hr;
716  TRACE("Relative Path-> %s\n", debugstr_w(m_sPathRel));
717  }
718 
720  {
721  hr = Stream_LoadString(stm, unicode, &m_sWorkDir);
722  if (FAILED(hr))
723  return hr;
725  TRACE("Working Dir -> %s\n", debugstr_w(m_sWorkDir));
726  }
727 
729  {
730  hr = Stream_LoadString(stm, unicode, &m_sArgs);
731  if (FAILED(hr))
732  return hr;
733  TRACE("Arguments -> %s\n", debugstr_w(m_sArgs));
734  }
735 
737  {
738  hr = Stream_LoadString(stm, unicode, &m_sIcoPath);
739  if (FAILED(hr))
740  return hr;
741  TRACE("Icon file -> %s\n", debugstr_w(m_sIcoPath));
742  }
743 
744  /* Now load the optional data block list */
746  if (FAILED(hr)) // FIXME: Should we fail?
747  return hr;
748 
749  if (TRACE_ON(shell))
750  {
751 #if (NTDDI_VERSION < NTDDI_LONGHORN)
753  {
754  hr = GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
755  if (SUCCEEDED(hr))
756  TRACE("Product -> %s\n", debugstr_w(sProduct));
757  }
758 #endif
760  {
762  if (SUCCEEDED(hr))
763  TRACE("Component -> %s\n", debugstr_w(sComponent));
764  }
765  }
766 
768  m_bRunAs = TRUE;
769  else
770  m_bRunAs = FALSE;
771 
772  TRACE("OK\n");
773 
774  pdump(m_pPidl);
775 
776  return S_OK;
777 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
#define ZeroMemory
Definition: winbase.h:1648
HRESULT WINAPI SHReadDataBlockList(IStream *lpStream, LPDBLIST *lppList)
Definition: clist.c:235
#define E_FAIL
Definition: ddrawi.h:102
#define EXP_DARWIN_ID_SIG
Definition: shlobj.h:1894
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
#define GetProcessHeap()
Definition: compat.h:404
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define _countof(array)
Definition: sndvol32.h:68
#define PathRemoveBackslash
Definition: shlwapi.h:1023
#define MAX_PATH
Definition: compat.h:26
HRESULT WINAPI ILLoadFromStream(IStream *pStream, LPITEMIDLIST *ppPidl)
Definition: pidl.c:284
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
#define S_OK
Definition: intsafe.h:59
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:248
unsigned int ULONG
Definition: retypes.h:1
HRESULT Read([out, size_is(cb), length_is(*pcbRead)] void *pv, [in] ULONG cb, [out] ULONG *pcbRead)
#define TRACE_ON(x)
Definition: compat.h:65
#define HeapFree(x, y, z)
Definition: compat.h:403
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ OnCommand()

void CShellLink::OnCommand ( HWND  hwndDlg,
int  id,
HWND  hwndCtl,
UINT  codeNotify 
)

FIXME open target directory

Definition at line 2895 of file CShellLink.cpp.

2896 {
2897  switch (id)
2898  {
2899  case IDC_SHORTCUT_FIND:
2905  return;
2906 
2908  {
2909  WCHAR wszPath[MAX_PATH] = L"";
2910 
2911  if (m_sIcoPath)
2912  wcscpy(wszPath, m_sIcoPath);
2913  else
2914  FindExecutableW(m_sPath, NULL, wszPath);
2915 
2917  if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
2918  {
2919  SetIconLocation(wszPath, IconIndex);
2920  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2921 
2922  HICON hIconLarge = CreateShortcutIcon(wszPath, IconIndex);
2923  if (hIconLarge)
2924  {
2925  if (m_hIcon)
2927  m_hIcon = hIconLarge;
2929  }
2930  }
2931  return;
2932  }
2933 
2934  case IDC_SHORTCUT_ADVANCED:
2935  {
2937  if (result == 1 || result == 0)
2938  {
2939  if (m_bRunAs != result)
2940  {
2941  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2942  }
2943 
2944  m_bRunAs = result;
2945  }
2946  return;
2947  }
2948  }
2949  if (codeNotify == EN_CHANGE)
2950  {
2951  if (!m_bInInit)
2952  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2953  }
2954 }
#define STM_SETICON
Definition: winuser.h:2074
static HICON
Definition: imagelist.c:84
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDD_SHORTCUT_EXTENDED_PROPERTIES
Definition: shresdef.h:347
#define IDC_SHORTCUT_ICON
Definition: shresdef.h:400
EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD dwFlags)
Definition: shlfolder.cpp:389
UINT_PTR WPARAM
Definition: windef.h:207
#define IDC_SHORTCUT_CHANGE_ICON
Definition: shresdef.h:417
int32_t INT_PTR
Definition: typedefs.h:63
int32_t INT
Definition: typedefs.h:57
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:350
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR IconIndex[]
Definition: install.c:52
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Definition: shlexec.cpp:1266
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define IDC_SHORTCUT_FIND
Definition: shresdef.h:416
HWND WINAPI GetParent(_In_ HWND)
#define IDC_SHORTCUT_ADVANCED
Definition: shresdef.h:418
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
GLuint64EXT * result
Definition: glext.h:11304
#define EN_CHANGE
Definition: winuser.h:2004

◆ OnDestroy()

void CShellLink::OnDestroy ( HWND  hwndDlg)

Definition at line 3016 of file CShellLink.cpp.

3017 {
3018  if (m_hIcon)
3019  {
3021  m_hIcon = NULL;
3022  }
3023 }
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
smooth NULL
Definition: ftsmooth.c:416

◆ OnInitDialog()

BOOL CShellLink::OnInitDialog ( HWND  hwndDlg,
HWND  hwndFocus,
LPARAM  lParam 
)

Definition at line 2823 of file CShellLink.cpp.

2824 {
2825  TRACE("CShellLink::OnInitDialog(hwnd %p hwndFocus %p lParam %p)\n", hwndDlg, hwndFocus, lParam);
2826 
2827  TRACE("m_sArgs: %S sComponent: %S m_sDescription: %S m_sIcoPath: %S m_sPath: %S m_sPathRel: %S sProduct: %S m_sWorkDir: %S\n", m_sArgs, sComponent, m_sDescription,
2829 
2830  m_bInInit = TRUE;
2831 
2832  /* Get file information */
2833  // FIXME! FIXME! Shouldn't we use m_sIcoPath, m_Header.nIconIndex instead???
2834  SHFILEINFOW fi;
2835  if (!SHGetFileInfoW(m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_ICON))
2836  {
2837  ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_sLinkPath, GetLastError());
2838  fi.szTypeName[0] = L'\0';
2839  fi.hIcon = NULL;
2840  }
2841 
2842  if (fi.hIcon)
2843  {
2844  if (m_hIcon)
2846  m_hIcon = fi.hIcon;
2848  }
2849  else
2850  ERR("ExtractIconW failed %ls %u\n", m_sIcoPath, m_Header.nIconIndex);
2851 
2852  /* Target type */
2853  if (m_sPath)
2855 
2856  /* Target location */
2857  if (m_sPath)
2858  {
2863  }
2864 
2865  /* Target path */
2866  if (m_sPath)
2867  {
2868  WCHAR newpath[2*MAX_PATH] = L"\0";
2869  if (wcschr(m_sPath, ' '))
2870  StringCchPrintfExW(newpath, _countof(newpath), NULL, NULL, 0, L"\"%ls\"", m_sPath);
2871  else
2872  StringCchCopyExW(newpath, _countof(newpath), m_sPath, NULL, NULL, 0);
2873 
2874  if (m_sArgs && m_sArgs[0])
2875  {
2876  StringCchCatW(newpath, _countof(newpath), L" ");
2877  StringCchCatW(newpath, _countof(newpath), m_sArgs);
2878  }
2879  SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, newpath);
2880  }
2881 
2882  /* Working dir */
2883  if (m_sWorkDir)
2885 
2886  /* Description */
2887  if (m_sDescription)
2889 
2890  m_bInInit = FALSE;
2891 
2892  return TRUE;
2893 }
#define STM_SETICON
Definition: winuser.h:2074
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:624
#define TRUE
Definition: types.h:120
#define IDC_SHORTCUT_TYPE_EDIT
Definition: shresdef.h:403
#define IDC_SHORTCUT_TARGET_TEXT
Definition: shresdef.h:407
#define SHGFI_TYPENAME
Definition: shellapi.h:165
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDC_SHORTCUT_ICON
Definition: shresdef.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
UINT_PTR WPARAM
Definition: windef.h:207
WCHAR szTypeName[80]
Definition: shellapi.h:374
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define IDC_SHORTCUT_LOCATION_EDIT
Definition: shresdef.h:405
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define IDC_SHORTCUT_COMMENT_EDIT
Definition: shresdef.h:415
smooth NULL
Definition: ftsmooth.c:416
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:389
#define TRACE(s)
Definition: solgame.cpp:4
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:413
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
HICON hIcon
Definition: shellapi.h:370
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
#define ERR(fmt,...)
Definition: debug.h:110
#define IDC_SHORTCUT_START_IN_EDIT
Definition: shresdef.h:409
GLenum target
Definition: glext.h:7315
#define SHGFI_ICON
Definition: shellapi.h:162
LPARAM lParam
Definition: combotst.c:139

◆ OnNotify()

LRESULT CShellLink::OnNotify ( HWND  hwndDlg,
int  idFrom,
LPNMHDR  pnmhdr 
)

Definition at line 2956 of file CShellLink.cpp.

2957 {
2958  WCHAR wszBuf[MAX_PATH];
2959  LPPSHNOTIFY lppsn = (LPPSHNOTIFY)pnmhdr;
2960 
2961  if (lppsn->hdr.code == PSN_APPLY)
2962  {
2963  /* set working directory */
2964  GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, wszBuf, _countof(wszBuf));
2965  SetWorkingDirectory(wszBuf);
2966 
2967  /* set link destination */
2968  GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf));
2969  LPWSTR lpszArgs = NULL;
2970  LPWSTR unquoted = strdupW(wszBuf);
2971  StrTrimW(unquoted, L" ");
2972 
2973  if (!PathFileExistsW(unquoted))
2974  {
2975  lpszArgs = PathGetArgsW(unquoted);
2976  PathRemoveArgsW(unquoted);
2977  StrTrimW(lpszArgs, L" ");
2978  }
2979  if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
2980  PathUnquoteSpacesW(unquoted);
2981 
2982  WCHAR *pwszExt = PathFindExtensionW(unquoted);
2983  if (!wcsicmp(pwszExt, L".lnk"))
2984  {
2985  // FIXME load localized error msg
2986  MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR);
2988  return TRUE;
2989  }
2990 
2991  if (!PathFileExistsW(unquoted))
2992  {
2993  // FIXME load localized error msg
2994  MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", L"Error", MB_ICONERROR);
2996  return TRUE;
2997  }
2998 
2999  SetPath(unquoted);
3000  if (lpszArgs)
3001  SetArguments(lpszArgs);
3002  else
3003  SetArguments(L"\0");
3004 
3005  HeapFree(GetProcessHeap(), 0, unquoted);
3006 
3007  TRACE("This %p m_sLinkPath %S\n", this, m_sLinkPath);
3008  Save(m_sLinkPath, TRUE);
3011  return TRUE;
3012  }
3013  return FALSE;
3014 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define TRUE
Definition: types.h:120
#define IDC_SHORTCUT_TARGET_TEXT
Definition: shresdef.h:407
void WINAPI PathRemoveArgsW(LPWSTR lpszPath)
Definition: path.c:774
struct _PSHNOTIFY * LPPSHNOTIFY
#define PSN_APPLY
Definition: prsht.h:117
#define SetWindowLongPtr
Definition: treelist.c:70
#define DWLP_MSGRESULT
Definition: winuser.h:864
UINT code
Definition: winuser.h:3134
NMHDR hdr
Definition: prsht.h:330
#define PSNRET_INVALID_NOCHANGEPAGE
Definition: prsht.h:131
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
#define PSNRET_NOERROR
Definition: prsht.h:129
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
static const WCHAR L[]
Definition: oid.c:1250
#define MB_ICONERROR
Definition: winuser.h:781
#define wcsicmp
Definition: string.h:1152
#define SHCNF_PATHW
Definition: shlobj.h:1764
LPWSTR WINAPI PathGetArgsW(LPCWSTR lpszPath)
Definition: path.c:501
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1029
#define IDC_SHORTCUT_START_IN_EDIT
Definition: shresdef.h:409
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1869
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1742
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ QueryContextMenu()

HRESULT STDMETHODCALLTYPE CShellLink::QueryContextMenu ( HMENU  hmenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
virtual

Implements IContextMenu.

Definition at line 2590 of file CShellLink.cpp.

2591 {
2592  INT id = 0;
2593 
2594  m_idCmdFirst = idCmdFirst;
2595 
2596  TRACE("%p %p %u %u %u %u\n", this,
2597  hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
2598 
2599  if (!hMenu)
2600  return E_INVALIDARG;
2601 
2604 
2605  MENUITEMINFOW mii;
2606  ZeroMemory(&mii, sizeof(mii));
2607  mii.cbSize = sizeof(mii);
2608  mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
2609  mii.dwTypeData = strOpen.GetBuffer();
2610  mii.cch = wcslen(mii.dwTypeData);
2611  mii.wID = idCmdFirst + id++;
2612  mii.fState = MFS_DEFAULT | MFS_ENABLED;
2613  mii.fType = MFT_STRING;
2614  if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2615  return E_FAIL;
2616 
2617  mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
2618  mii.dwTypeData = strOpenFileLoc.GetBuffer();
2619  mii.cch = wcslen(mii.dwTypeData);
2620  mii.wID = idCmdFirst + id++;
2621  mii.fState = MFS_ENABLED;
2622  mii.fType = MFT_STRING;
2623  if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2624  return E_FAIL;
2625 
2626  UNREFERENCED_PARAMETER(indexMenu);
2627 
2628  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, id);
2629 }
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IDS_OPENFILELOCATION
Definition: shresdef.h:231
#define ZeroMemory
Definition: winbase.h:1648
LPWSTR dwTypeData
Definition: winuser.h:3244
#define IDS_OPEN_VERB
Definition: shresdef.h:197
UINT uFlags
Definition: api.c:59
#define MFS_DEFAULT
Definition: winuser.h:743
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:57
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define MFS_ENABLED
Definition: winuser.h:745
#define MIIM_STATE
Definition: winuser.h:716
#define E_INVALIDARG
Definition: ddrawi.h:101
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define MIIM_ID
Definition: winuser.h:717
#define TRACE(s)
Definition: solgame.cpp:4
#define MIIM_TYPE
Definition: winuser.h:720
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ RemoveDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::RemoveDataBlock ( DWORD  dwSig)
virtual

Implements IShellLinkDataList.

Definition at line 2519 of file CShellLink.cpp.

2520 {
2521  if (SHRemoveDataBlock(&m_pDBList, dwSig))
2522  {
2523  m_bDirty = TRUE;
2524  return S_OK;
2525  }
2526  return S_FALSE;
2527 }
#define TRUE
Definition: types.h:120
#define S_FALSE
Definition: winerror.h:2357
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI SHRemoveDataBlock(LPDBLIST *lppList, DWORD dwSignature)
Definition: clist.c:355

Referenced by SetIconLocation(), SetPath(), and WriteAdvertiseInfo().

◆ ReplacePage()

HRESULT STDMETHODCALLTYPE CShellLink::ReplacePage ( UINT  uPageID,
LPFNADDPROPSHEETPAGE  pfnReplacePage,
LPARAM  lParam 
)
virtual

Definition at line 3085 of file CShellLink.cpp.

3086 {
3087  TRACE("(%p) (uPageID %u, pfnReplacePage %p lParam %p\n", this, uPageID, pfnReplacePage, lParam);
3088  return E_NOTIMPL;
3089 }
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99
LPARAM lParam
Definition: combotst.c:139

◆ Reset()

VOID CShellLink::Reset ( void  )
private

Definition at line 220 of file CShellLink.cpp.

221 {
222  ILFree(m_pPidl);
223  m_pPidl = NULL;
224 
226  m_sPath = NULL;
227  ZeroMemory(&volume, sizeof(volume));
228 
232  m_sPathRel = NULL;
234  m_sWorkDir = NULL;
236  m_sArgs = NULL;
238  m_sIcoPath = NULL;
239 
240  m_bRunAs = FALSE;
241  m_bDirty = FALSE;
242 
243  if (m_pDBList)
245  m_pDBList = NULL;
246 
248 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define ZeroMemory
Definition: winbase.h:1648
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:404
VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList)
Definition: clist.c:331
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by Load().

◆ Resolve()

HRESULT STDMETHODCALLTYPE CShellLink::Resolve ( HWND  hwnd,
DWORD  fFlags 
)
virtual

Implements IShellLinkA.

Definition at line 1390 of file CShellLink.cpp.

1391 {
1392  HRESULT hr = S_OK;
1393  BOOL bSuccess;
1394 
1395  TRACE("(%p)->(hwnd=%p flags=%x)\n", this, hwnd, fFlags);
1396 
1397  /* FIXME: use IResolveShellLink interface? */
1398 
1399  // FIXME: See InvokeCommand().
1400 
1401 #if (NTDDI_VERSION < NTDDI_LONGHORN)
1402  // NOTE: For Logo3 (EXP_LOGO3_ID_SIG), check also for SHRestricted(REST_NOLOGO3CHANNELNOTIFY)
1404  {
1405  FIXME("Logo3 links are not supported yet!\n");
1406  return E_FAIL;
1407  }
1408 #endif
1409 
1410  /* Resolve Darwin (MSI) target */
1412  {
1413  LPWSTR component = NULL;
1414  hr = GetAdvertiseInfo(&component, EXP_DARWIN_ID_SIG);
1415  if (FAILED(hr))
1416  return E_FAIL;
1417 
1418  /* Clear the cached path */
1421  if (!m_sPath)
1422  return E_FAIL;
1423  }
1424 
1425  if (!m_sPath && m_pPidl)
1426  {
1428 
1430  if (bSuccess && *buffer)
1431  {
1432  m_sPath = strdupW(buffer);
1433  if (!m_sPath)
1434  return E_OUTOFMEMORY;
1435 
1436  m_bDirty = TRUE;
1437  }
1438  else
1439  {
1440  hr = S_OK; /* don't report an error occurred while just caching information */
1441  }
1442  }
1443 
1444  // FIXME: Strange to do that here...
1445  if (!m_sIcoPath && m_sPath)
1446  {
1448  if (!m_sIcoPath)
1449  return E_OUTOFMEMORY;
1450 
1451  m_Header.nIconIndex = 0;
1452 
1453  m_bDirty = TRUE;
1454  }
1455 
1456  return hr;
1457 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1288
GLuint buffer
Definition: glext.h:5915
#define E_FAIL
Definition: ddrawi.h:102
static BOOLEAN bSuccess
Definition: drive.cpp:419
#define EXP_DARWIN_ID_SIG
Definition: shlobj.h:1894
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define MAX_PATH
Definition: compat.h:26
#define S_OK
Definition: intsafe.h:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by InvokeCommand().

◆ Save() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::Save ( LPCOLESTR  pszFileName,
BOOL  fRemember 
)
virtual

Implements IPersistFile.

Definition at line 345 of file CShellLink.cpp.

346 {
347  BOOL bAlreadyExists;
348  WCHAR szFullPath[MAX_PATH];
349 
350  TRACE("(%p)->(%s)\n", this, debugstr_w(pszFileName));
351 
352  if (!pszFileName)
353  return E_FAIL;
354 
355  bAlreadyExists = PathFileExistsW(pszFileName);
356 
357  CComPtr<IStream> stm;
359  if (SUCCEEDED(hr))
360  {
361  hr = Save(stm, FALSE);
362 
363  if (SUCCEEDED(hr))
364  {
365  GetFullPathNameW(pszFileName, _countof(szFullPath), szFullPath, NULL);
366  if (bAlreadyExists)
368  else
370 
371  if (m_sLinkPath)
373 
375  m_bDirty = FALSE;
376  }
377  else
378  {
380  WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName));
381  }
382  }
383 
384  return hr;
385 }
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define WARN(fmt,...)
Definition: debug.h:112
#define STGM_CREATE
Definition: objbase.h:925
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
#define E_FAIL
Definition: ddrawi.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
#define STGM_READWRITE
Definition: objbase.h:918
#define SHCNF_PATHW
Definition: shlobj.h:1764
HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
Definition: istream.c:484
#define SHCNE_CREATE
Definition: shlobj.h:1730
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1742
#define HeapFree(x, y, z)
Definition: compat.h:403
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by OnNotify().

◆ Save() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::Save ( IStream stm,
BOOL  fClearDirty 
)
virtual

Implements IPersistStream.

Definition at line 870 of file CShellLink.cpp.

871 {
872  TRACE("%p %p %x\n", this, stm, fClearDirty);
873 
874  m_Header.dwSize = sizeof(m_Header);
875  m_Header.clsid = CLSID_ShellLink;
876 
877  /*
878  * Reset the flags: keep only the flags related to data blocks as they were
879  * already set in accordance by the different mutator member functions.
880  * The other flags will be determined now by the presence or absence of data.
881  */
884 #if (NTDDI_VERSION < NTDDI_LONGHORN)
886 #endif
888  // TODO: When we will support Vista+ functionality, add other flags to this list.
889 
890  /* The stored strings are in UNICODE */
892 
893  if (m_pPidl)
895  if (m_sPath)
899  if (m_sPathRel && *m_sPathRel)
901  if (m_sWorkDir && *m_sWorkDir)
903  if (m_sArgs && *m_sArgs)
905  if (m_sIcoPath && *m_sIcoPath)
907  if (m_bRunAs)
909 
910  /* Write the shortcut header */
911  ULONG count;
912  HRESULT hr = stm->Write(&m_Header, sizeof(m_Header), &count);
913  if (FAILED(hr))
914  {
915  ERR("Write failed\n");
916  return hr;
917  }
918 
919  /* Save the data in order */
920 
921  if (m_pPidl)
922  {
923  hr = ILSaveToStream(stm, m_pPidl);
924  if (FAILED(hr))
925  {
926  ERR("Failed to write PIDL\n");
927  return hr;
928  }
929  }
930 
931  if (m_sPath)
932  {
934  if (FAILED(hr))
935  return hr;
936  }
937 
939  {
941  if (FAILED(hr))
942  return hr;
943  }
944 
946  {
948  if (FAILED(hr))
949  return hr;
950  }
951 
953  {
955  if (FAILED(hr))
956  return hr;
957  }
958 
960  {
961  hr = Stream_WriteString(stm, m_sArgs);
962  if (FAILED(hr))
963  return hr;
964  }
965 
967  {
969  if (FAILED(hr))
970  return hr;
971  }
972 
973  /*
974  * Now save the data block list.
975  *
976  * NOTE that both advertised Product and Component are already saved
977  * inside Logo3 and Darwin data blocks in the m_pDBList list, and the
978  * m_Header.dwFlags is suitably initialized.
979  */
981  if (FAILED(hr))
982  return hr;
983 
984  /* Clear the dirty bit if requested */
985  if (fClearDirty)
986  m_bDirty = FALSE;
987 
988  return hr;
989 }
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
HRESULT WINAPI ILSaveToStream(IStream *pStream, LPCITEMIDLIST pPidl)
Definition: pidl.c:342
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
HRESULT WINAPI SHWriteDataBlockList(IStream *lpStream, LPDBLIST lpList)
Definition: clist.c:179
#define ERR(fmt,...)
Definition: debug.h:110
unsigned int ULONG
Definition: retypes.h:1
HRESULT Write([in, size_is(cb)] const void *pv, [in] ULONG cb, [out] ULONG *pcbWritten)

◆ SaveCompleted()

HRESULT STDMETHODCALLTYPE CShellLink::SaveCompleted ( LPCOLESTR  pszFileName)
virtual

Implements IPersistFile.

Definition at line 387 of file CShellLink.cpp.

388 {
389  FIXME("(%p)->(%s)\n", this, debugstr_w(pszFileName));
390  return S_OK;
391 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
#define S_OK
Definition: intsafe.h:59

◆ SetAdvertiseInfo()

HRESULT CShellLink::SetAdvertiseInfo ( LPCWSTR  str)
private

Definition at line 2097 of file CShellLink.cpp.

2098 {
2099  HRESULT hr;
2100  LPCWSTR szComponent = NULL, szProduct = NULL, p;
2101  INT len;
2102  GUID guid;
2103  WCHAR szGuid[38+1];
2104 
2105  sProduct = sComponent = NULL;
2106 
2107  while (str[0])
2108  {
2109  /* each segment must start with two colons */
2110  if (str[0] != ':' || str[1] != ':')
2111  return E_FAIL;
2112 
2113  /* the last segment is just two colons */
2114  if (!str[2])
2115  break;
2116  str += 2;
2117 
2118  /* there must be a colon straight after a guid */
2119  p = wcschr(str, L':');
2120  if (!p)
2121  return E_FAIL;
2122  len = p - str;
2123  if (len != 38)
2124  return E_FAIL;
2125 
2126  /* get the guid, and check if it's validly formatted */
2127  memcpy(szGuid, str, sizeof(WCHAR)*len);
2128  szGuid[len] = 0;
2129 
2131  if (hr != S_OK)
2132  return hr;
2133  str = p + 1;
2134 
2135  /* match it up to a guid that we care about */
2136  if (IsEqualGUID(guid, SHELL32_AdvtShortcutComponent) && !szComponent)
2137  szComponent = str; /* Darwin */
2138  else if (IsEqualGUID(guid, SHELL32_AdvtShortcutProduct) && !szProduct)
2139  szProduct = str; /* Logo3 */
2140  else
2141  return E_FAIL;
2142 
2143  /* skip to the next field */
2144  str = wcschr(str, L':');
2145  if (!str)
2146  return E_FAIL;
2147  }
2148 
2149  /* we have to have a component for an advertised shortcut */
2150  if (!szComponent)
2151  return E_FAIL;
2152 
2153  szComponent = GetAdvertisedArg(szComponent);
2154  szProduct = GetAdvertisedArg(szProduct);
2155 
2156  hr = WriteAdvertiseInfo(szComponent, EXP_DARWIN_ID_SIG);
2157  // if (FAILED(hr))
2158  // return hr;
2159 #if (NTDDI_VERSION < NTDDI_LONGHORN)
2160  hr = WriteAdvertiseInfo(szProduct, EXP_LOGO3_ID_SIG);
2161  // if (FAILED(hr))
2162  // return hr;
2163 #endif
2164 
2165  HeapFree(GetProcessHeap(), 0, (PVOID)szComponent);
2166  HeapFree(GetProcessHeap(), 0, (PVOID)szProduct);
2167 
2168  if (TRACE_ON(shell))
2169  {
2171  TRACE("Component = %s\n", debugstr_w(sComponent));
2172 #if (NTDDI_VERSION < NTDDI_LONGHORN)
2173  GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
2174  TRACE("Product = %s\n", debugstr_w(sProduct));
2175 #endif
2176  }
2177 
2178  return S_OK;
2179 }
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define E_FAIL
Definition: ddrawi.h:102
const GUID SHELL32_AdvtShortcutComponent
int32_t INT
Definition: typedefs.h:57
const GUID * guid
#define EXP_DARWIN_ID_SIG
Definition: shlobj.h:1894
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
const GUID SHELL32_AdvtShortcutProduct
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
static const WCHAR szGuid[]
Definition: rtlstr.c:1892
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
GLfloat GLfloat p
Definition: glext.h:8902
#define TRACE_ON(x)
Definition: compat.h:65
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by SetPath().

◆ SetArguments() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCSTR  pszArgs)
virtual

Implements IShellLinkA.

Definition at line 1209 of file CShellLink.cpp.

1210 {
1211  TRACE("(%p)->(args=%s)\n", this, pszArgs);
1212 
1214  m_sArgs = NULL;
1215 
1216  if (pszArgs)
1217  {
1218  m_sArgs = HEAP_strdupAtoW(GetProcessHeap(), 0, pszArgs);
1219  if (!m_sArgs)
1220  return E_OUTOFMEMORY;
1221  }
1222  m_bDirty = TRUE;
1223 
1224  return S_OK;
1225 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by OnNotify().

◆ SetArguments() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCWSTR  pszArgs)
virtual

Implements IShellLinkW.

Definition at line 1630 of file CShellLink.cpp.

1631 {
1632  TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs));
1633 
1635  m_sArgs = NULL;
1636 
1637  if (pszArgs)
1638  {
1639  m_sArgs = strdupW(pszArgs);
1640  if (!m_sArgs)
1641  return E_OUTOFMEMORY;
1642  }
1643  m_bDirty = TRUE;
1644 
1645  return S_OK;
1646 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ SetDescription() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCSTR  pszName)
virtual

Implements IShellLinkA.

Definition at line 1145 of file CShellLink.cpp.

1146 {
1147  TRACE("(%p)->(pName=%s)\n", this, pszName);
1148 
1150  m_sDescription = NULL;
1151 
1152  if (pszName)
1153  {
1155  if (!m_sDescription)
1156  return E_OUTOFMEMORY;
1157  }
1158  m_bDirty = TRUE;
1159 
1160  return S_OK;
1161 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ SetDescription() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCWSTR  pszName)
virtual

Implements IShellLinkW.

Definition at line 1568 of file CShellLink.cpp.

1569 {
1570  TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
1571 
1573  m_sDescription = NULL;
1574 
1575  if (pszName)
1576  {
1577  m_sDescription = strdupW(pszName);
1578  if (!m_sDescription)
1579  return E_OUTOFMEMORY;
1580  }
1581  m_bDirty = TRUE;
1582 
1583  return S_OK;
1584 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ SetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::SetFlags ( DWORD  dwFlags)
virtual

Implements IShellLinkDataList.

Definition at line 2536 of file CShellLink.cpp.

2537 {
2538 #if 0 // FIXME!
2540  m_bDirty = TRUE;
2541  return S_OK;
2542 #else
2543  FIXME("\n");
2544  return E_NOTIMPL;
2545 #endif
2546 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:111
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ SetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::SetHotkey ( WORD  wHotkey)
virtual

Implements IShellLinkA.

Definition at line 1234 of file CShellLink.cpp.

1235 {
1236  TRACE("(%p)->(hotkey=%x)\n", this, wHotkey);
1237 
1238  m_Header.wHotKey = wHotkey;
1239  m_bDirty = TRUE;
1240 
1241  return S_OK;
1242 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ SetIconLocation() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetIconLocation ( LPCSTR  pszIconPath,
INT  iIcon 
)
virtual

Definition at line 1331 of file CShellLink.cpp.

1332 {
1333  TRACE("(%p)->(path=%s iicon=%u)\n", this, pszIconPath, iIcon);
1334 
1335  LPWSTR str = NULL;
1336  if (pszIconPath)
1337  {
1338  str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
1339  if (!str)
1340  return E_OUTOFMEMORY;
1341  }
1342 
1343  HRESULT hr = SetIconLocation(str, iIcon);
1344 
1345  if (str)
1346  HeapFree(GetProcessHeap(), 0, str);
1347 
1348  return hr;
1349 }
HRESULT hr
Definition: shlfolder.c:183
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:404
LONG HRESULT
Definition: typedefs.h:78
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by OnCommand().

◆ SetIconLocation() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetIconLocation ( LPCWSTR  pszIconPath,
INT  iIcon 
)
virtual

Definition at line 1868 of file CShellLink.cpp.

1869 {
1870  HRESULT hr = E_FAIL;
1871  WCHAR szIconPath[MAX_PATH];
1872 
1873  TRACE("(%p)->(path=%s iicon=%u)\n", this, debugstr_w(pszIconPath), iIcon);
1874 
1875  if (pszIconPath)
1876  {
1877  /*
1878  * Check whether the user-given file path contains unexpanded
1879  * environment variables. If so, create a target environment block.
1880  * Note that in this block we will store the user-given path.
1881  * It will contain the unexpanded environment variables, but
1882  * it can also contain already expanded path that the user does
1883  * not want to see them unexpanded (e.g. so that they always
1884  * refer to the same place even if the would-be corresponding
1885  * environment variable could change).
1886  */
1887 #ifdef ICON_LINK_WINDOWS_COMPAT
1888  /* Try to fully unexpand the icon path */
1889  // if (PathFullyUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath)))
1890  BOOL bSuccess = PathUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath));
1891  if (bSuccess && wcscmp(pszIconPath, szIconPath) != 0)
1892 #else
1893  /*
1894  * In some situations, described in http://stackoverflow.com/questions/2976489/ishelllinkseticonlocation-translates-my-icon-path-into-program-files-which-i
1895  * the result of PathUnExpandEnvStringsW() could be wrong, and instead
1896  * one would have to store the actual provided icon location path, while
1897  * creating an icon environment block ONLY if that path already contains
1898  * environment variables. This is what the present case is trying to implement.
1899  */
1900  SHExpandEnvironmentStringsW(pszIconPath, szIconPath, _countof(szIconPath));
1901  if (wcscmp(pszIconPath, szIconPath) != 0)
1902 #endif
1903  {
1904  /*
1905  * The user-given file path contains unexpanded environment
1906  * variables, so we need an icon environment block.
1907  */
1909  LPEXP_SZ_LINK pInfo;
1910 
1911 #ifdef ICON_LINK_WINDOWS_COMPAT
1912  /* Make pszIconPath point to the unexpanded path */
1913  LPCWSTR pszOrgIconPath = pszIconPath;
1914  pszIconPath = szIconPath;
1915 #endif
1917  if (pInfo)
1918  {
1919  /* Make sure that the size of the structure is valid */
1920  if (pInfo->cbSize != sizeof(*pInfo))
1921  {
1922  ERR("Ooops. This structure is not as expected...\n");
1923 
1924  /* Invalid structure, remove it altogether */
1927 
1928  /* Reset the pointer and go use the static buffer */
1929  pInfo = NULL;
1930  }
1931  }
1932  if (!pInfo)
1933  {
1934  /* Use the static buffer */
1935  pInfo = &buffer;
1936  buffer.cbSize = sizeof(buffer);
1937  buffer.dwSignature = EXP_SZ_ICON_SIG;
1938  }
1939 
1940  lstrcpynW(pInfo->szwTarget, pszIconPath, _countof(pInfo->szwTarget));
1941  WideCharToMultiByte(CP_ACP, 0, pszIconPath, -1,
1942  pInfo->szTarget, _countof(pInfo->szTarget), NULL, NULL);
1943 
1944  hr = S_OK;
1945  if (pInfo == &buffer)
1946  hr = AddDataBlock(pInfo);
1947  if (hr == S_OK)