ReactOS 0.4.16-dev-747-gbc52d5f
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 IContextMenuLPCONTEXTMENU
 
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 IExtractIconA
typedef IExtractIconALPEXTRACTICONA
 
- 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)
 
STDMETHOD() GetClassID (CLSID *pclsid) override
 
STDMETHOD() IsDirty () override
 
STDMETHOD() Load (LPCOLESTR pszFileName, DWORD dwMode) override
 
STDMETHOD() Save (LPCOLESTR pszFileName, BOOL fRemember) override
 
STDMETHOD() SaveCompleted (LPCOLESTR pszFileName) override
 
STDMETHOD() GetCurFile (LPOLESTR *ppszFileName) override
 
STDMETHOD() Load (IStream *stm) override
 
STDMETHOD() Save (IStream *stm, BOOL fClearDirty) override
 
STDMETHOD() GetSizeMax (ULARGE_INTEGER *pcbSize) override
 
STDMETHOD() GetPath (LPSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags) override
 
STDMETHOD() GetIDList (PIDLIST_ABSOLUTE *ppidl) override
 
STDMETHOD() SetIDList (PCIDLIST_ABSOLUTE pidl) override
 
STDMETHOD() GetDescription (LPSTR pszName, INT cchMaxName) override
 
STDMETHOD() SetDescription (LPCSTR pszName) override
 
STDMETHOD() GetWorkingDirectory (LPSTR pszDir, INT cchMaxPath) override
 
STDMETHOD() SetWorkingDirectory (LPCSTR pszDir) override
 
STDMETHOD() GetArguments (LPSTR pszArgs, INT cchMaxPath) override
 
STDMETHOD() SetArguments (LPCSTR pszArgs) override
 
STDMETHOD() GetHotkey (WORD *pwHotkey) override
 
STDMETHOD() SetHotkey (WORD wHotkey) override
 
STDMETHOD() GetShowCmd (INT *piShowCmd) override
 
STDMETHOD() SetShowCmd (INT iShowCmd) override
 
STDMETHOD() GetIconLocation (LPSTR pszIconPath, INT cchIconPath, INT *piIcon) override
 
STDMETHOD() SetIconLocation (LPCSTR pszIconPath, INT iIcon) override
 
STDMETHOD() SetRelativePath (LPCSTR pszPathRel, DWORD dwReserved) override
 
STDMETHOD() Resolve (HWND hwnd, DWORD fFlags) override
 
STDMETHOD() SetPath (LPCSTR pszFile) override
 
STDMETHOD() GetPath (LPWSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags) override
 
STDMETHOD() GetDescription (LPWSTR pszName, INT cchMaxName) override
 
STDMETHOD() SetDescription (LPCWSTR pszName) override
 
STDMETHOD() GetWorkingDirectory (LPWSTR pszDir, INT cchMaxPath) override
 
STDMETHOD() SetWorkingDirectory (LPCWSTR pszDir) override
 
STDMETHOD() GetArguments (LPWSTR pszArgs, INT cchMaxPath) override
 
STDMETHOD() SetArguments (LPCWSTR pszArgs) override
 
STDMETHOD() GetIconLocation (LPWSTR pszIconPath, INT cchIconPath, INT *piIcon) override
 
STDMETHOD() SetIconLocation (LPCWSTR pszIconPath, INT iIcon) override
 
STDMETHOD() SetRelativePath (LPCWSTR pszPathRel, DWORD dwReserved) override
 
STDMETHOD() SetPath (LPCWSTR pszFile) override
 
STDMETHOD() AddDataBlock (void *pDataBlock) override
 
STDMETHOD() CopyDataBlock (DWORD dwSig, void **ppDataBlock) override
 
STDMETHOD() RemoveDataBlock (DWORD dwSig) override
 
STDMETHOD() GetFlags (DWORD *pdwFlags) override
 
STDMETHOD() SetFlags (DWORD dwFlags) override
 
STDMETHOD() Extract (PCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) override
 
STDMETHOD() GetIconLocation (UINT uFlags, PSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags) override
 
STDMETHOD() Extract (PCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) override
 
STDMETHOD() GetIconLocation (UINT uFlags, PWSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags) override
 
STDMETHOD() Initialize (PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override
 
STDMETHOD() QueryContextMenu (HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override
 
STDMETHOD() InvokeCommand (LPCMINVOKECOMMANDINFO lpici) override
 
STDMETHOD() GetCommandString (UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax) override
 
STDMETHOD() AddPages (LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam) override
 
STDMETHOD() ReplacePage (UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam) override
 
STDMETHOD() SetSite (IUnknown *punk) override
 
STDMETHOD() GetSite (REFIID iid, void **ppvSite) override
 
STDMETHOD() DragEnter (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
 
STDMETHOD() DragOver (DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
 
STDMETHOD() DragLeave () override
 
STDMETHOD() Drop (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
 
- 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 GetIDList ([out] PIDLIST_ABSOLUTE *ppidl)
 
HRESULT SetIDList ([in] PCIDLIST_ABSOLUTE pidl)
 
HRESULT GetDescription ([out, size_is(cch)] LPSTR pszName, [in] int cch)
 
HRESULT SetDescription ([in] LPCSTR pszName)
 
HRESULT GetWorkingDirectory ([out, size_is(cch)] LPSTR pszDir, [in] int cch)
 
HRESULT SetWorkingDirectory ([in] LPCSTR pszDir)
 
HRESULT GetArguments ([out, size_is(cch)] LPSTR pszArgs, [in] int cch)
 
HRESULT SetArguments ([in] LPCSTR pszArgs)
 
HRESULT GetHotkey ([out] WORD *pwHotkey)
 
HRESULT SetHotkey ([in] WORD wHotkey)
 
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)
 
HRESULT SetRelativePath ([in] LPCSTR pszPathRel, [in] DWORD dwReserved)
 
HRESULT Resolve ([in] HWND hwnd, [in] DWORD fFlags)
 
HRESULT SetPath ([in] LPCSTR pszFile)
 
- 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 GetIDList ([out] PIDLIST_ABSOLUTE *ppidl)
 
HRESULT SetIDList ([in] PCIDLIST_ABSOLUTE pidl)
 
HRESULT GetDescription ([out, size_is(cch)] LPWSTR pszName, [in] int cch)
 
HRESULT SetDescription ([in] LPCWSTR pszName)
 
HRESULT GetWorkingDirectory ([out, size_is(cch)] LPWSTR pszDir, [in] int cch)
 
HRESULT SetWorkingDirectory ([in] LPCWSTR pszDir)
 
HRESULT GetArguments ([out, size_is(cch)] LPWSTR pszArgs, [in] int cch)
 
HRESULT SetArguments ([in] LPCWSTR pszArgs)
 
HRESULT GetHotkey ([out] WORD *pwHotkey)
 
HRESULT SetHotkey ([in] WORD wHotkey)
 
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)
 
HRESULT SetRelativePath ([in] LPCWSTR pszPathRel, [in] DWORD dwReserved)
 
HRESULT Resolve ([in] HWND hwnd, [in] DWORD fFlags)
 
HRESULT SetPath ([in] LPCWSTR pszFile)
 
HRESULT IsDirty ()
 
HRESULT Load ([in, unique] IStream *pStm)
 
HRESULT Save ([in, unique] IStream *pStm, [in] BOOL fClearDirty)
 
HRESULT GetSizeMax ([out] ULARGE_INTEGER *pcbSize)
 
HRESULT GetClassID ([out] CLSID *pClassID)
 
HRESULT IsDirty ()
 
HRESULT Load ([in] LPCOLESTR pszFileName, [in] DWORD dwMode)
 
HRESULT Save ([in, unique] LPCOLESTR pszFileName, [in] BOOL fRemember)
 
HRESULT SaveCompleted ([in, unique] LPCOLESTR pszFileName)
 
HRESULT GetCurFile ([out] LPOLESTR *ppszFileName)
 
HRESULT Initialize ([in] PCIDLIST_ABSOLUTE pidlFolder, [in] IDataObject *pdtobj, [in] HKEY hkeyProgID)
 
HRESULT QueryContextMenu ([in] HMENU hmenu, [in] UINT indexMenu, [in] UINT idCmdFirst, [in] UINT idCmdLast, [in] UINT uFlags)
 
HRESULT InvokeCommand ([in] LPCMINVOKECOMMANDINFO lpici)
 
HRESULT GetCommandString ([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
 
HRESULT DragEnter ([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
HRESULT DragOver ([in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
HRESULT DragLeave ()
 
HRESULT Drop ([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
HRESULT AddDataBlock ([in] void *pDataBlock)
 
HRESULT CopyDataBlock ([in] DWORD dwSig, [out] void **ppDataBlock)
 
HRESULT RemoveDataBlock ([in] DWORD dwSig)
 
HRESULT GetFlags ([out] DWORD *pdwFlags)
 
HRESULT SetFlags ([in] DWORD dwFlags)
 
- 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)
 
HRESULT Extract ([in] LPCSTR pszFile, [in] UINT nIconIndex, [out] HICON *phiconLarge, [out] HICON *phiconSmall, [in] UINT nIconSize)
 
- 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 SetSite ([in] IUnknown *pUnkSite)
 
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 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
 
- Static Public Attributes inherited from IContextMenu
static 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.

63 {
64 IDCMD_OPEN = 0,
66 };

Constructor & Destructor Documentation

◆ CShellLink()

CShellLink::CShellLink ( )

Definition at line 266 of file CShellLink.cpp.

267{
268 m_Header.dwSize = sizeof(m_Header);
269 m_Header.clsid = CLSID_ShellLink;
270 m_Header.dwFlags = 0;
271
277
280 m_Header.wHotKey = 0;
281
282 m_pPidl = NULL;
283
284 m_sPath = NULL;
285 ZeroMemory(&volume, sizeof(volume));
286
290 m_sArgs = NULL;
292 m_bRunAs = FALSE;
293 m_bDirty = FALSE;
294 m_pDBList = NULL;
296 m_hIcon = NULL;
297 m_idCmdFirst = 0;
298
300
302}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define ZeroMemory
Definition: winbase.h:1737
#define SW_SHOWNORMAL
Definition: winuser.h:773

◆ ~CShellLink()

CShellLink::~CShellLink ( )

Definition at line 304 of file CShellLink.cpp.

305{
306 TRACE("-- destroying IShellLink(%p)\n", this);
307
309
311
319}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList)
Definition: clist.c:331
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1044
#define TRACE(s)
Definition: solgame.cpp:4

Member Function Documentation

◆ AddDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::AddDataBlock ( void pDataBlock)
override

Implements IShellLinkDataList.

Definition at line 2435 of file CShellLink.cpp.

2436{
2437 if (SHAddDataBlock(&m_pDBList, (DATABLOCK_HEADER*)pDataBlock))
2438 {
2439 m_bDirty = TRUE;
2440 return S_OK;
2441 }
2442 return S_FALSE;
2443}
#define TRUE
Definition: types.h:120
BOOL WINAPI SHAddDataBlock(LPDBLIST *lppList, const DATABLOCK_HEADER *lpNewItem)
Definition: clist.c:68
#define S_OK
Definition: intsafe.h:52
#define S_FALSE
Definition: winerror.h:2357

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

◆ AddPages()

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

Definition at line 3107 of file CShellLink.cpp.

3108{
3110 (LPARAM)this, NULL, &PropSheetPageLifetimeCallback<CShellLink>);
3111 HRESULT hr = AddPropSheetPage(hPage, pfnAddPage, lParam);
3113 return hr;
3114 else
3115 AddRef(); // For PropSheetPageLifetimeCallback
3116 enum { CShellLink_PageIndex_Shortcut = 0 };
3117 return 1 + CShellLink_PageIndex_Shortcut; // Make this page the default (one-based)
3118}
LPARAM lParam
Definition: combotst.c:139
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
static HRESULT AddPropSheetPage(HPROPSHEETPAGE hPage, LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
Definition: precomp.h:150
ULONG AddRef()
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
HRESULT hr
Definition: shlfolder.c:183
#define IDD_SHORTCUT_PROPERTIES
Definition: shresdef.h:401
HPROPSHEETPAGE SH_CreatePropertySheetPageEx(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle, LPFNPSPCALLBACK Callback)
Definition: propsheet.cpp:223
LONG_PTR LPARAM
Definition: windef.h:208

◆ CopyDataBlock()

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

Implements IShellLinkDataList.

Definition at line 2445 of file CShellLink.cpp.

2446{
2447 DATABLOCK_HEADER* pBlock;
2448 PVOID pDataBlock;
2449
2450 TRACE("%p %08x %p\n", this, dwSig, ppDataBlock);
2451
2452 *ppDataBlock = NULL;
2453
2454 pBlock = SHFindDataBlock(m_pDBList, dwSig);
2455 if (!pBlock)
2456 {
2457 ERR("unknown datablock %08x (not found)\n", dwSig);
2458 return E_FAIL;
2459 }
2460
2461 pDataBlock = LocalAlloc(LMEM_ZEROINIT, pBlock->cbSize);
2462 if (!pDataBlock)
2463 return E_OUTOFMEMORY;
2464
2465 CopyMemory(pDataBlock, pBlock, pBlock->cbSize);
2466
2467 *ppDataBlock = pDataBlock;
2468 return S_OK;
2469}
#define ERR(fmt,...)
Definition: precomp.h:57
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define LMEM_ZEROINIT
Definition: winbase.h:401
#define CopyMemory
Definition: winbase.h:1735

◆ CreateShortcutIcon()

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

Definition at line 3222 of file CShellLink.cpp.

3223{
3225 const COLORREF crMask = GetSysColor(COLOR_3DFACE);
3226 WCHAR wszLnkIcon[MAX_PATH];
3227 int lnk_idx;
3228 HDC hDC;
3230 HICON hIcon = NULL, hNewIcon = NULL, hShortcut;
3231
3232 if (HLM_GetIconW(IDI_SHELL_SHORTCUT - 1, wszLnkIcon, _countof(wszLnkIcon), &lnk_idx))
3233 {
3234 ::ExtractIconExW(wszLnkIcon, lnk_idx, &hShortcut, NULL, 1);
3235 }
3236 else
3237 {
3239 IMAGE_ICON, cx, cy, 0);
3240 }
3241
3242 ::ExtractIconExW(wszIconPath, IconIndex, &hIcon, NULL, 1);
3243 if (!hIcon || !hShortcut || !himl)
3244 goto cleanup;
3245
3247 if (hDC)
3248 {
3249 // create 32bpp bitmap
3250 BITMAPINFO bi;
3251 ZeroMemory(&bi, sizeof(bi));
3252 bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3253 bi.bmiHeader.biWidth = cx;
3254 bi.bmiHeader.biHeight = cy;
3255 bi.bmiHeader.biPlanes = 1;
3256 bi.bmiHeader.biBitCount = 32;
3257 LPVOID pvBits;
3258 HBITMAP hbm = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
3259 if (hbm)
3260 {
3261 // draw the icon image
3262 HGDIOBJ hbmOld = SelectObject(hDC, hbm);
3263 {
3264 HBRUSH hbr = CreateSolidBrush(crMask);
3265 RECT rc = { 0, 0, cx, cy };
3266 FillRect(hDC, &rc, hbr);
3267 DeleteObject(hbr);
3268
3269 DrawIconEx(hDC, 0, 0, hIcon, cx, cy, 0, NULL, DI_NORMAL);
3270 DrawIconEx(hDC, 0, 0, hShortcut, cx, cy, 0, NULL, DI_NORMAL);
3271 }
3272 SelectObject(hDC, hbmOld);
3273
3274 INT iAdded = ImageList_AddMasked(himl, hbm, crMask);
3275 hNewIcon = ImageList_GetIcon(himl, iAdded, ILD_NORMAL | ILD_TRANSPARENT);
3276
3278 }
3279 DeleteDC(hDC);
3280 }
3281
3282cleanup:
3283 if (hIcon)
3285 if (hShortcut)
3286 DestroyIcon(hShortcut);
3287 if (himl)
3289
3290 return hNewIcon;
3291}
static HDC hDC
Definition: 3dtext.c:33
#define shell32_hInstance
HIMAGELIST himl
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:935
HICON WINAPI ImageList_GetIcon(HIMAGELIST himl, INT i, UINT fStyle)
Definition: imagelist.c:1970
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:567
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:808
#define MAX_PATH
Definition: compat.h:34
static void cleanup(void)
Definition: main.c:1335
static const WCHAR IconIndex[]
Definition: install.c:52
pKey DeleteObject()
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:855
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define ILD_NORMAL
Definition: commctrl.h:417
_Out_opt_ int * cx
Definition: commctrl.h:585
#define ILC_COLOR32
Definition: commctrl.h:358
#define ILD_TRANSPARENT
Definition: commctrl.h:418
#define ILC_MASK
Definition: commctrl.h:351
#define IDI_SHELL_SHORTCUT
Definition: shresdef.h:582
#define _countof(array)
Definition: sndvol32.h:70
USHORT biBitCount
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
int32_t INT
Definition: typedefs.h:58
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
DWORD COLORREF
Definition: windef.h:300
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DI_NORMAL
Definition: wingdi.h:72
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
DWORD WINAPI GetSysColor(_In_ int)
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2289
#define SM_CYICON
Definition: winuser.h:976
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:2114
#define SM_CXICON
Definition: winuser.h:975
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2139
#define COLOR_3DFACE
Definition: winuser.h:932
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnCommand().

◆ DoOpen()

HRESULT CShellLink::DoOpen ( LPCMINVOKECOMMANDINFO  lpici)
private

Definition at line 2632 of file CShellLink.cpp.

2633{
2635 const BOOL unicode = IsUnicode(*lpici);
2636
2637 CStringW args;
2638 if (m_sArgs)
2639 args = m_sArgs;
2640
2641 if (unicode)
2642 {
2643 if (!StrIsNullOrEmpty(iciex->lpParametersW))
2644 {
2645 args += L' ';
2646 args += iciex->lpParametersW;
2647 }
2648 }
2649 else
2650 {
2651 CComHeapPtr<WCHAR> pszParams;
2652 if (!StrIsNullOrEmpty(lpici->lpParameters) && __SHCloneStrAtoW(&pszParams, lpici->lpParameters))
2653 {
2654 args += L' ';
2655 args += pszParams;
2656 }
2657 }
2658
2660 SHELLEXECUTEINFOW sei = { sizeof(sei) };
2663 sei.lpDirectory = m_sWorkDir;
2664 if (m_pPidl)
2665 {
2666 sei.lpIDList = m_pPidl;
2668 }
2669 else
2670 {
2671 sei.lpFile = m_sPath;
2673 {
2674 sei.fMask &= ~SEE_MASK_DOENVSUBST; // The link does not want to expand lpFile
2676 sei.lpDirectory = dir;
2677 }
2678 }
2679 sei.lpParameters = args;
2680 sei.lpClass = m_sLinkPath;
2682 if (lpici->nShow != SW_SHOWNORMAL && lpici->nShow != SW_SHOW)
2683 sei.nShow = lpici->nShow; // Allow invoker to override .lnk show mode
2684
2685 // Use the invoker specified working directory if the link did not specify one
2686 if (StrIsNullOrEmpty(sei.lpDirectory) || !PathEnvSubstIsDirectory(sei.lpDirectory))
2687 {
2688 LPCSTR pszDirA = lpici->lpDirectory;
2689 if (unicode && !StrIsNullOrEmpty(iciex->lpDirectoryW))
2690 sei.lpDirectory = iciex->lpDirectoryW;
2691 else if (pszDirA && SHAnsiToUnicode(pszDirA, dir, _countof(dir)))
2692 sei.lpDirectory = dir;
2693 }
2694 return (ShellExecuteExW(&sei) ? S_OK : E_FAIL);
2695}
unsigned int dir
Definition: maze.c:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2673
unsigned int BOOL
Definition: ntddk_ex.h:94
struct IContextMenu::tagCMInvokeCommandInfoEx * LPCMINVOKECOMMANDINFOEX
if(dx< 0)
Definition: linetemp.h:194
#define L(x)
Definition: ntvdm.h:50
static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
Definition: shell32_main.h:178
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:35
#define SEE_MASK_UNICODE
Definition: shellapi.h:37
#define SEE_MASK_ASYNCOK
Definition: shellapi.h:54
#define SEE_MASK_NOASYNC
Definition: shellapi.h:33
#define SEE_MASK_INVOKEIDLIST
Definition: shellapi.h:28
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:36
#define SEE_MASK_HASLINKNAME
Definition: shellapi.h:49
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2452
@ SLDF_HAS_EXP_SZ
Definition: shlobj.h:1953
LPCWSTR lpDirectory
Definition: shellapi.h:335
LPCWSTR lpParameters
Definition: shellapi.h:334
Definition: match.c:390
#define SW_SHOW
Definition: winuser.h:778
const char * LPCSTR
Definition: xmlstorage.h:183

◆ DoOpenFileLocation()

HRESULT CShellLink::DoOpenFileLocation ( )
private

Definition at line 2583 of file CShellLink.cpp.

2584{
2585 WCHAR szParams[MAX_PATH + 64];
2586 StringCbPrintfW(szParams, sizeof(szParams), L"/select,%s", m_sPath);
2587
2588 INT_PTR ret;
2589 ret = reinterpret_cast<INT_PTR>(ShellExecuteW(NULL, NULL, L"explorer.exe", szParams,
2591 if (ret <= 32)
2592 {
2593 ERR("ret: %08lX\n", ret);
2594 return E_FAIL;
2595 }
2596
2597 return S_OK;
2598}
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2507
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
int32_t INT_PTR
Definition: typedefs.h:64
int ret

Referenced by InvokeCommand().

◆ DragEnter()

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

Implements IDropTarget.

Definition at line 3145 of file CShellLink.cpp.

3147{
3148 TRACE("(%p)->(DataObject=%p)\n", this, pDataObject);
3149
3150 if (*pdwEffect == DROPEFFECT_NONE)
3151 return S_OK;
3152
3154 if (SUCCEEDED(hr))
3155 hr = m_DropTarget->DragEnter(pDataObject, dwKeyState, pt, pdwEffect);
3156 else
3157 *pdwEffect = DROPEFFECT_NONE;
3158
3159 return S_OK;
3160}
EXTERN_C HRESULT SHELL_GetUIObjectOfAbsoluteItem(_In_opt_ HWND hWnd, _In_ PCIDLIST_ABSOLUTE pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:380
#define pt(x, y)
Definition: drawing.c:79
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define IID_PPV_ARG(Itype, ppType)

◆ DragLeave()

HRESULT STDMETHODCALLTYPE CShellLink::DragLeave ( void  )
override

Implements IDropTarget.

Definition at line 3172 of file CShellLink.cpp.

3173{
3174 TRACE("(%p)\n", this);
3175 HRESULT hr = S_OK;
3176 if (m_DropTarget)
3177 {
3178 hr = m_DropTarget->DragLeave();
3180 }
3181
3182 return hr;
3183}
void Release()
Definition: atlcomcli.h:170

◆ DragOver()

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

Implements IDropTarget.

Definition at line 3162 of file CShellLink.cpp.

3164{
3165 TRACE("(%p)\n", this);
3166 HRESULT hr = S_OK;
3167 if (m_DropTarget)
3168 hr = m_DropTarget->DragOver(dwKeyState, pt, pdwEffect);
3169 return hr;
3170}

◆ Drop()

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

Implements IDropTarget.

Definition at line 3185 of file CShellLink.cpp.

3187{
3188 TRACE("(%p)\n", this);
3189 HRESULT hr = S_OK;
3190 if (m_DropTarget)
3191 hr = m_DropTarget->Drop(pDataObject, dwKeyState, pt, pdwEffect);
3192
3193 return hr;
3194}

◆ Extract() [1/2]

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

Implements IExtractIconA.

Definition at line 1366 of file CShellLink.cpp.

1367{
1368 TRACE("(%p)->(path=%s iicon=%u)\n", this, pszFile, nIconIndex);
1369
1370 LPWSTR str = NULL;
1371 if (pszFile)
1372 {
1373 str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1374 if (!str)
1375 return E_OUTOFMEMORY;
1376 }
1377
1378 HRESULT hr = Extract(str, nIconIndex, phiconLarge, phiconSmall, nIconSize);
1379
1380 if (str)
1382
1383 return hr;
1384}
const WCHAR * str
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Extract().

◆ Extract() [2/2]

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

Definition at line 1800 of file CShellLink.cpp.

1801{
1802 HRESULT hr = NOERROR;
1803 UINT cxyLarge = LOWORD(nIconSize), cxySmall = HIWORD(nIconSize);
1804
1805 if (phiconLarge)
1806 {
1807 *phiconLarge = NULL;
1808 PrivateExtractIconsW(pszFile, nIconIndex, cxyLarge, cxyLarge, phiconLarge, NULL, 1, 0);
1809
1810 if (*phiconLarge == NULL)
1811 hr = S_FALSE;
1812 }
1813
1814 if (phiconSmall)
1815 {
1816 *phiconSmall = NULL;
1817 PrivateExtractIconsW(pszFile, nIconIndex, cxySmall, cxySmall, phiconSmall, NULL, 1, 0);
1818
1819 if (*phiconSmall == NULL)
1820 hr = S_FALSE;
1821 }
1822
1823 if (hr == S_FALSE)
1824 {
1825 if (phiconLarge && *phiconLarge)
1826 {
1827 DestroyIcon(*phiconLarge);
1828 *phiconLarge = NULL;
1829 }
1830 if (phiconSmall && *phiconSmall)
1831 {
1832 DestroyIcon(*phiconSmall);
1833 *phiconSmall = NULL;
1834 }
1835 }
1836
1837 return hr;
1838}
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define HIWORD(l)
Definition: typedefs.h:247
#define NOERROR
Definition: winerror.h:2354
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)

◆ GetAdvertiseInfo()

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

Definition at line 621 of file CShellLink.cpp.

622{
623 LPEXP_DARWIN_LINK pInfo;
624
625 *str = NULL;
626
628 if (!pInfo)
629 return E_FAIL;
630
631 /* Make sure that the size of the structure is valid */
632 if (pInfo->dbh.cbSize != sizeof(*pInfo))
633 {
634 ERR("Ooops. This structure is not as expected...\n");
635 return E_FAIL;
636 }
637
638 TRACE("dwSig %08x string = '%s'\n", pInfo->dbh.dwSignature, debugstr_w(pInfo->szwDarwinID));
639
640 *str = pInfo->szwDarwinID;
641 return S_OK;
642}
#define debugstr_w
Definition: kernel32.h:32
struct EXP_DARWIN_LINK * LPEXP_DARWIN_LINK

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

◆ GetArguments() [1/2]

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

Definition at line 1250 of file CShellLink.cpp.

1251{
1252 TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1253
1254 if (cchMaxPath)
1255 *pszArgs = 0;
1256
1257 if (m_sArgs)
1259 pszArgs, cchMaxPath, NULL, NULL);
1260
1261 return S_OK;
1262}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111

◆ GetArguments() [2/2]

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

Definition at line 1672 of file CShellLink.cpp.

1673{
1674 TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1675
1676 if (cchMaxPath)
1677 *pszArgs = 0;
1678
1679 if (m_sArgs)
1680 lstrcpynW(pszArgs, m_sArgs, cchMaxPath);
1681
1682 return S_OK;
1683}
#define lstrcpynW
Definition: compat.h:738

◆ GetClassID()

HRESULT STDMETHODCALLTYPE CShellLink::GetClassID ( CLSID pclsid)
override

Implements IPersist.

Definition at line 321 of file CShellLink.cpp.

322{
323 TRACE("%p %p\n", this, pclsid);
324
325 if (pclsid == NULL)
326 return E_POINTER;
327 *pclsid = CLSID_ShellLink;
328 return S_OK;
329}
#define E_POINTER
Definition: winerror.h:2365

◆ GetCommandString()

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

Implements IContextMenu.

Definition at line 2697 of file CShellLink.cpp.

2698{
2699 FIXME("%p %lu %u %p %p %u\n", this, idCmd, uType, pwReserved, pszName, cchMax);
2700 return E_NOTIMPL;
2701}
UINT cchMax
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetCurFile()

HRESULT STDMETHODCALLTYPE CShellLink::GetCurFile ( LPOLESTR ppszFileName)
override

Implements IPersistFile.

Definition at line 409 of file CShellLink.cpp.

410{
411 *ppszFileName = NULL;
412
413 if (!m_sLinkPath)
414 {
415 /* IPersistFile::GetCurFile called before IPersistFile::Save */
416 return S_FALSE;
417 }
418
419 *ppszFileName = (LPOLESTR)CoTaskMemAlloc((wcslen(m_sLinkPath) + 1) * sizeof(WCHAR));
420 if (!*ppszFileName)
421 {
422 /* out of memory */
423 return E_OUTOFMEMORY;
424 }
425
426 /* copy last saved filename */
427 wcscpy(*ppszFileName, m_sLinkPath);
428
429 return S_OK;
430}
wcscpy
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static LPOLESTR
Definition: stg_prop.c:27

◆ GetDescription() [1/2]

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

Definition at line 1186 of file CShellLink.cpp.

1187{
1188 TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1189
1190 if (cchMaxName)
1191 *pszName = 0;
1192
1193 if (m_sDescription)
1195 pszName, cchMaxName, NULL, NULL);
1196
1197 return S_OK;
1198}

◆ GetDescription() [2/2]

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

Definition at line 1612 of file CShellLink.cpp.

1613{
1614 TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1615
1616 *pszName = 0;
1617 if (m_sDescription)
1618 lstrcpynW(pszName, m_sDescription, cchMaxName);
1619
1620 return S_OK;
1621}

◆ GetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::GetFlags ( DWORD pdwFlags)
override

Implements IShellLinkDataList.

Definition at line 2481 of file CShellLink.cpp.

2482{
2483 TRACE("%p %p\n", this, pdwFlags);
2484 *pdwFlags = m_Header.dwFlags;
2485 return S_OK;
2486}

◆ GetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::GetHotkey ( WORD pwHotkey)
override

Implements IShellLinkA.

Definition at line 1282 of file CShellLink.cpp.

1283{
1284 TRACE("(%p)->(%p)(0x%08x)\n", this, pwHotkey, m_Header.wHotKey);
1285 *pwHotkey = m_Header.wHotKey;
1286 return S_OK;
1287}

◆ GetIconLocation() [1/4]

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

Definition at line 1316 of file CShellLink.cpp.

1317{
1318 HRESULT hr;
1319 LPWSTR pszIconPathW;
1320
1321 TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1322
1323 /* Allocate a temporary UNICODE buffer */
1324 pszIconPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchIconPath * sizeof(WCHAR));
1325 if (!pszIconPathW)
1326 return E_OUTOFMEMORY;
1327
1328 /* Call the UNICODE function */
1329 hr = GetIconLocation(pszIconPathW, cchIconPath, piIcon);
1330
1331 /* Convert the file path back to ANSI */
1332 WideCharToMultiByte(CP_ACP, 0, pszIconPathW, -1,
1333 pszIconPath, cchIconPath, NULL, NULL);
1334
1335 /* Free the temporary buffer */
1336 HeapFree(GetProcessHeap(), 0, pszIconPathW);
1337
1338 return hr;
1339}
#define HeapAlloc
Definition: compat.h:733

Referenced by GetIconLocation().

◆ GetIconLocation() [2/4]

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

Definition at line 1703 of file CShellLink.cpp.

1704{
1705 TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1706
1707 if (cchIconPath)
1708 *pszIconPath = 0;
1709
1710 *piIcon = 0;
1711
1712 /* Update the original icon path location */
1714 {
1716
1717 /* Search for an icon environment block */
1718 LPEXP_SZ_LINK pInfo;
1720 if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1721 {
1723
1724 m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
1726
1728 if (!m_sIcoPath)
1729 return E_OUTOFMEMORY;
1730
1732
1733 m_bDirty = TRUE;
1734 }
1735 }
1736
1737 *piIcon = m_Header.nIconIndex;
1738
1739 if (m_sIcoPath)
1740 lstrcpynW(pszIconPath, m_sIcoPath, cchIconPath);
1741
1742 return S_OK;
1743}
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
LPCWSTR szPath
Definition: env.c:37
@ SLDF_HAS_EXP_ICON_SZ
Definition: shlobj.h:1960
@ SLDF_HAS_ICONLOCATION
Definition: shlobj.h:1950
#define EXP_SZ_ICON_SIG
Definition: shlobj.h:2059
struct EXP_SZ_LINK * LPEXP_SZ_LINK
DWORD WINAPI SHExpandEnvironmentStringsW(LPCWSTR, LPWSTR, DWORD)

◆ GetIconLocation() [3/4]

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

Definition at line 1341 of file CShellLink.cpp.

1342{
1343 HRESULT hr;
1344 LPWSTR pszIconFileW;
1345
1346 TRACE("(%p)->(%u %p len=%u piIndex=%p pwFlags=%p)\n", this, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1347
1348 /* Allocate a temporary UNICODE buffer */
1349 pszIconFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR));
1350 if (!pszIconFileW)
1351 return E_OUTOFMEMORY;
1352
1353 /* Call the UNICODE function */
1354 hr = GetIconLocation(uFlags, pszIconFileW, cchMax, piIndex, pwFlags);
1355
1356 /* Convert the file path back to ANSI */
1357 WideCharToMultiByte(CP_ACP, 0, pszIconFileW, -1,
1358 pszIconFile, cchMax, NULL, NULL);
1359
1360 /* Free the temporary buffer */
1361 HeapFree(GetProcessHeap(), 0, pszIconFileW);
1362
1363 return hr;
1364}
UINT uFlags
Definition: api.c:59

◆ GetIconLocation() [4/4]

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

Definition at line 1759 of file CShellLink.cpp.

1760{
1761 HRESULT hr;
1762
1763 pszIconFile[0] = UNICODE_NULL;
1764
1765 /*
1766 * It is possible for a shell link to point to another shell link,
1767 * and in particular there is the possibility to point to itself.
1768 * Now, suppose we ask such a link to retrieve its associated icon.
1769 * This function would be called, and due to COM would be called again
1770 * recursively. To solve this issue, we forbid calling GetIconLocation()
1771 * with GIL_FORSHORTCUT set in uFlags, as done by Windows (shown by tests).
1772 */
1773 if (uFlags & GIL_FORSHORTCUT)
1774 return E_INVALIDARG;
1775
1776 /*
1777 * Now, we set GIL_FORSHORTCUT so that: i) we allow the icon extractor
1778 * of the target to give us a suited icon, and ii) we protect ourselves
1779 * against recursive call.
1780 */
1781 uFlags |= GIL_FORSHORTCUT;
1782
1783 if (uFlags & GIL_DEFAULTICON)
1784 return S_FALSE;
1785
1786 hr = GetIconLocation(pszIconFile, cchMax, piIndex);
1787 if (FAILED(hr) || pszIconFile[0] == UNICODE_NULL)
1788 {
1789 hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1790 }
1791 else
1792 {
1793 *pwFlags = GIL_NOTFILENAME | GIL_PERCLASS;
1794 }
1795
1796 return hr;
1797}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define FAILED(hr)
Definition: intsafe.h:51
#define UNICODE_NULL

◆ GetIDList()

HRESULT STDMETHODCALLTYPE CShellLink::GetIDList ( PIDLIST_ABSOLUTE ppidl)
override

Implements IShellLinkA.

Definition at line 1166 of file CShellLink.cpp.

1167{
1168 TRACE("(%p)->(ppidl=%p)\n", this, ppidl);
1169
1170 if (!m_pPidl)
1171 {
1172 *ppidl = NULL;
1173 return S_FALSE;
1174 }
1175
1176 *ppidl = ILClone(m_pPidl);
1177 return S_OK;
1178}
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237

Referenced by OnInitDialog().

◆ GetPath() [1/2]

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

Definition at line 1117 of file CShellLink.cpp.

1118{
1119 HRESULT hr;
1120 LPWSTR pszFileW;
1121 WIN32_FIND_DATAW wfd;
1122
1123 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1124 this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1125
1126 /* Allocate a temporary UNICODE buffer */
1127 pszFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, max(cchMaxPath, MAX_PATH) * sizeof(WCHAR));
1128 if (!pszFileW)
1129 return E_OUTOFMEMORY;
1130
1131 /* Call the UNICODE function */
1132 hr = GetPath(pszFileW, cchMaxPath, &wfd, fFlags);
1133
1134 /* Convert the file path back to ANSI */
1135 WideCharToMultiByte(CP_ACP, 0, pszFileW, -1,
1136 pszFile, cchMaxPath, NULL, NULL);
1137
1138 /* Free the temporary buffer */
1139 HeapFree(GetProcessHeap(), 0, pszFileW);
1140
1141 if (pfd)
1142 {
1143 ZeroMemory(pfd, sizeof(*pfd));
1144
1145 /* Copy the file data if a file path was returned */
1146 if (*pszFile)
1147 {
1148 DWORD len;
1149
1150 /* Copy the fixed part */
1151 CopyMemory(pfd, &wfd, FIELD_OFFSET(WIN32_FIND_DATAA, cFileName));
1152
1153 /* Convert the file names to ANSI */
1154 len = lstrlenW(wfd.cFileName);
1155 WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, len + 1,
1156 pfd->cFileName, sizeof(pfd->cFileName), NULL, NULL);
1157 len = lstrlenW(wfd.cAlternateFileName);
1158 WideCharToMultiByte(CP_ACP, 0, wfd.cAlternateFileName, len + 1,
1159 pfd->cAlternateFileName, sizeof(pfd->cAlternateFileName), NULL, NULL);
1160 }
1161 }
1162
1163 return hr;
1164}
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
#define max(a, b)
Definition: svc.c:63
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by GetPath(), OnInitDialog(), and Save().

◆ GetPath() [2/2]

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

Definition at line 1531 of file CShellLink.cpp.

1532{
1534
1535 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1536 this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1537
1538 if (cchMaxPath)
1539 *pszFile = 0;
1540 // FIXME: What if cchMaxPath == 0 , or pszFile == NULL ??
1541
1542 // FIXME: What about Darwin??
1543
1544 /*
1545 * Retrieve the path to the target from the PIDL (if we have one).
1546 * NOTE: Do NOT use the cached path (m_sPath from link info).
1547 */
1549 {
1550 if (fFlags & SLGP_SHORTPATH)
1552 // FIXME: Add support for SLGP_UNCPRIORITY
1553 }
1554 else
1555 {
1556 *buffer = 0;
1557 }
1558
1559 /* If we have a FindData structure, initialize it */
1560 if (pfd)
1561 {
1562 ZeroMemory(pfd, sizeof(*pfd));
1563
1564 /* Copy the file data if the target is a file path */
1565 if (*buffer)
1566 {
1567 pfd->dwFileAttributes = m_Header.dwFileAttributes;
1568 pfd->ftCreationTime = m_Header.ftCreationTime;
1569 pfd->ftLastAccessTime = m_Header.ftLastAccessTime;
1570 pfd->ftLastWriteTime = m_Header.ftLastWriteTime;
1571 pfd->nFileSizeHigh = 0;
1572 pfd->nFileSizeLow = m_Header.nFileSizeLow;
1573
1574 /*
1575 * Build temporarily a short path in pfd->cFileName (of size MAX_PATH),
1576 * then extract and store the short file name in pfd->cAlternateFileName.
1577 */
1578 GetShortPathNameW(buffer, pfd->cFileName, _countof(pfd->cFileName));
1579 lstrcpynW(pfd->cAlternateFileName,
1580 PathFindFileNameW(pfd->cFileName),
1581 _countof(pfd->cAlternateFileName));
1582
1583 /* Now extract and store the long file name in pfd->cFileName */
1584 lstrcpynW(pfd->cFileName,
1586 _countof(pfd->cFileName));
1587 }
1588 }
1589
1590 /* Finally check if we have a raw path the user actually wants to retrieve */
1591 if ((fFlags & SLGP_RAWPATH) && (m_Header.dwFlags & SLDF_HAS_EXP_SZ))
1592 {
1593 /* Search for a target environment block */
1594 LPEXP_SZ_LINK pInfo;
1596 if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1597 lstrcpynW(buffer, pInfo->szwTarget, cchMaxPath);
1598 }
1599
1600 /* For diagnostics purposes only... */
1601 // NOTE: SLGP_UNCPRIORITY is unsupported
1602 fFlags &= ~(SLGP_RAWPATH | SLGP_SHORTPATH);
1603 if (fFlags) FIXME("(%p): Unsupported flags %lu\n", this, fFlags);
1604
1605 /* Copy the data back to the user */
1606 if (*buffer)
1607 lstrcpynW(pszFile, buffer, cchMaxPath);
1608
1609 return (*buffer ? S_OK : S_FALSE);
1610}
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1833
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1454
#define EXP_SZ_LINK_SIG
Definition: shlobj.h:2051

◆ GetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::GetShowCmd ( INT piShowCmd)
override

Definition at line 1299 of file CShellLink.cpp.

1300{
1301 TRACE("(%p)->(%p) %d\n", this, piShowCmd, m_Header.nShowCommand);
1302 *piShowCmd = m_Header.nShowCommand;
1303 return S_OK;
1304}

◆ GetSite()

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

Definition at line 3135 of file CShellLink.cpp.

3136{
3137 TRACE("%p %s %p\n", this, debugstr_guid(&iid), ppvSite);
3138
3139 if (m_site == NULL)
3140 return E_FAIL;
3141
3142 return m_site->QueryInterface(iid, ppvSite);
3143}
#define debugstr_guid
Definition: kernel32.h:35

◆ GetSizeMax()

HRESULT STDMETHODCALLTYPE CShellLink::GetSizeMax ( ULARGE_INTEGER pcbSize)
override

Implements IPersistStream.

Definition at line 1049 of file CShellLink.cpp.

1050{
1051 TRACE("(%p)\n", this);
1052 return E_NOTIMPL;
1053}

◆ GetWorkingDirectory() [1/2]

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

Definition at line 1218 of file CShellLink.cpp.

1219{
1220 TRACE("(%p)->(%p len=%u)\n", this, pszDir, cchMaxPath);
1221
1222 if (cchMaxPath)
1223 *pszDir = 0;
1224
1225 if (m_sWorkDir)
1227 pszDir, cchMaxPath, NULL, NULL);
1228
1229 return S_OK;
1230}
_In_ LPCSTR pszDir
Definition: shellapi.h:585

◆ GetWorkingDirectory() [2/2]

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

Definition at line 1641 of file CShellLink.cpp.

1642{
1643 TRACE("(%p)->(%p len %u)\n", this, pszDir, cchMaxPath);
1644
1645 if (cchMaxPath)
1646 *pszDir = 0;
1647
1648 if (m_sWorkDir)
1649 lstrcpynW(pszDir, m_sWorkDir, cchMaxPath);
1650
1651 return S_OK;
1652}

◆ Initialize()

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

Implements IShellExtInit.

Definition at line 2505 of file CShellLink.cpp.

2506{
2507 TRACE("%p %p %p %p\n", this, pidlFolder, pdtobj, hkeyProgID);
2508
2509 if (!pdtobj)
2510 return E_FAIL;
2511
2512 FORMATETC format;
2513 format.cfFormat = CF_HDROP;
2514 format.ptd = NULL;
2515 format.dwAspect = DVASPECT_CONTENT;
2516 format.lindex = -1;
2517 format.tymed = TYMED_HGLOBAL;
2518
2519 STGMEDIUM stgm;
2520 HRESULT hr = pdtobj->GetData(&format, &stgm);
2521 if (FAILED(hr))
2522 return hr;
2523
2524 UINT count = DragQueryFileW((HDROP)stgm.hGlobal, -1, NULL, 0);
2525 if (count == 1)
2526 {
2527 count = DragQueryFileW((HDROP)stgm.hGlobal, 0, NULL, 0);
2528 count++;
2529 LPWSTR path = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
2530 if (path)
2531 {
2532 count = DragQueryFileW((HDROP)stgm.hGlobal, 0, path, count);
2533 hr = Load(path, 0);
2535 }
2536 }
2537 ReleaseStgMedium(&stgm);
2538
2539 return S_OK;
2540}
#define CF_HDROP
Definition: constants.h:410
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:622
GLuint GLuint GLsizei count
Definition: gl.h:1545
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
Definition: format.c:58

◆ InvokeCommand()

HRESULT STDMETHODCALLTYPE CShellLink::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
override

Implements IContextMenu.

Definition at line 2600 of file CShellLink.cpp.

2601{
2602 TRACE("%p %p\n", this, lpici);
2603
2604 if (lpici->cbSize < sizeof(CMINVOKECOMMANDINFO))
2605 return E_INVALIDARG;
2606
2607 // NOTE: We could use lpici->hwnd (certainly in case lpici->fMask doesn't contain CMIC_MASK_FLAG_NO_UI)
2608 // as the parent window handle... ?
2609 /* FIXME: get using interface set from IObjectWithSite?? */
2610 // NOTE: We might need an extended version of Resolve that provides us with paths...
2611 HRESULT hr = Resolve(lpici->hwnd, (lpici->fMask & CMIC_MASK_FLAG_NO_UI) ? SLR_NO_UI : 0);
2612 if (FAILED(hr))
2613 {
2614 TRACE("failed to resolve component error 0x%08x\n", hr);
2615 return hr;
2616 }
2617
2618 UINT idCmd = LOWORD(lpici->lpVerb);
2619 TRACE("idCmd: %d\n", idCmd);
2620
2621 switch (idCmd)
2622 {
2623 case IDCMD_OPEN:
2624 return DoOpen(lpici);
2626 return DoOpenFileLocation();
2627 default:
2628 return E_NOTIMPL;
2629 }
2630}
struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
int DoOpen(void)
Definition: cmds.c:2168

◆ IsDirty()

HRESULT STDMETHODCALLTYPE CShellLink::IsDirty ( void  )
override

Implements IPersistStream.

Definition at line 334 of file CShellLink.cpp.

335{
336 TRACE("(%p)\n", this);
337 return (m_bDirty ? S_OK : S_FALSE);
338}

◆ Load() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::Load ( IStream stm)
override

Implements IPersistStream.

Definition at line 647 of file CShellLink.cpp.

648{
649 TRACE("%p %p\n", this, stm);
650
651 if (!stm)
653
654 /* Free all the old stuff */
655 Reset();
656
657 ULONG dwBytesRead = 0;
658 HRESULT hr = stm->Read(&m_Header, sizeof(m_Header), &dwBytesRead);
659 if (FAILED(hr))
660 return hr;
661
662 if (dwBytesRead != sizeof(m_Header))
663 return E_FAIL;
664 if (m_Header.dwSize != sizeof(m_Header))
665 return E_FAIL;
666 if (!IsEqualIID(m_Header.clsid, CLSID_ShellLink))
667 return E_FAIL;
668
669 /* Load the new data in order */
670
671 if (TRACE_ON(shell))
672 {
673 SYSTEMTIME stCreationTime;
674 SYSTEMTIME stLastAccessTime;
675 SYSTEMTIME stLastWriteTime;
676 WCHAR sTemp[MAX_PATH];
677
681
683 NULL, sTemp, _countof(sTemp));
684 TRACE("-- stCreationTime: %s\n", debugstr_w(sTemp));
686 NULL, sTemp, _countof(sTemp));
687 TRACE("-- stLastAccessTime: %s\n", debugstr_w(sTemp));
689 NULL, sTemp, _countof(sTemp));
690 TRACE("-- stLastWriteTime: %s\n", debugstr_w(sTemp));
691 }
692
693 /* load all the new stuff */
695 {
696 hr = ILLoadFromStream(stm, &m_pPidl);
697 if (FAILED(hr))
698 return hr;
699 }
700 pdump(m_pPidl);
701
702 /* Load the location information... */
704 {
706 if (FAILED(hr))
707 return hr;
708 }
709 /* ... but if it is required not to use it, clear it */
711 {
713 m_sPath = NULL;
714 ZeroMemory(&volume, sizeof(volume));
715 }
716
717 BOOL unicode = !!(m_Header.dwFlags & SLDF_UNICODE);
718
720 {
721 hr = Stream_LoadString(stm, unicode, &m_sDescription);
722 if (FAILED(hr))
723 return hr;
724 TRACE("Description -> %s\n", debugstr_w(m_sDescription));
725 }
726
728 {
729 hr = Stream_LoadString(stm, unicode, &m_sPathRel);
730 if (FAILED(hr))
731 return hr;
732 TRACE("Relative Path-> %s\n", debugstr_w(m_sPathRel));
733 }
734
736 {
737 hr = Stream_LoadString(stm, unicode, &m_sWorkDir);
738 if (FAILED(hr))
739 return hr;
741 TRACE("Working Dir -> %s\n", debugstr_w(m_sWorkDir));
742 }
743
745 {
746 hr = Stream_LoadString(stm, unicode, &m_sArgs);
747 if (FAILED(hr))
748 return hr;
749 TRACE("Arguments -> %s\n", debugstr_w(m_sArgs));
750 }
751
753 {
754 hr = Stream_LoadString(stm, unicode, &m_sIcoPath);
755 if (FAILED(hr))
756 return hr;
757 TRACE("Icon file -> %s\n", debugstr_w(m_sIcoPath));
758 }
759
760 /* Now load the optional data block list */
762 if (FAILED(hr)) // FIXME: Should we fail?
763 return hr;
764
766 if (pSpecial && pSpecial->cbSize == sizeof(*pSpecial) && ILGetSize(m_pPidl) > pSpecial->cbOffset)
767 {
769 {
770 LPITEMIDLIST pidl = ILCombine(folder, (LPITEMIDLIST)((char*)m_pPidl + pSpecial->cbOffset));
771 if (pidl)
772 {
774 m_pPidl = pidl;
775 TRACE("Replaced pidl base with CSIDL %u up to %ub.\n", pSpecial->idSpecialFolder, pSpecial->cbOffset);
776 }
777 ILFree(folder);
778 }
779 }
780
781 if (TRACE_ON(shell))
782 {
783#if (NTDDI_VERSION < NTDDI_LONGHORN)
785 {
786 hr = GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
787 if (SUCCEEDED(hr))
788 TRACE("Product -> %s\n", debugstr_w(sProduct));
789 }
790#endif
792 {
794 if (SUCCEEDED(hr))
795 TRACE("Component -> %s\n", debugstr_w(sComponent));
796 }
797 }
798
800 m_bRunAs = TRUE;
801 else
802 m_bRunAs = FALSE;
803
804 TRACE("OK\n");
805
806 pdump(m_pPidl);
807
808 return S_OK;
809}
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:322
#define TRACE_ON(x)
Definition: compat.h:75
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
HRESULT WINAPI SHReadDataBlockList(IStream *lpStream, LPDBLIST *lppList)
Definition: clist.c:235
HRESULT Read([out, size_is(cb), length_is(*pcbRead)] void *pv, [in] ULONG cb, [out] ULONG *pcbRead)
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:993
#define LOCALE_USER_DEFAULT
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:445
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:816
HRESULT WINAPI ILLoadFromStream(IStream *pStream, LPITEMIDLIST *ppPidl)
Definition: pidl.c:293
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define ILGetSize
Definition: shellclasses.h:638
#define EXP_DARWIN_ID_SIG
Definition: shlobj.h:2055
@ SLDF_HAS_RELPATH
Definition: shlobj.h:1947
@ SLDF_HAS_ID_LIST
Definition: shlobj.h:1944
@ SLDF_HAS_DARWINID
Definition: shlobj.h:1958
@ SLDF_HAS_LINK_INFO
Definition: shlobj.h:1945
@ SLDF_HAS_WORKINGDIR
Definition: shlobj.h:1948
@ SLDF_HAS_ARGS
Definition: shlobj.h:1949
@ SLDF_FORCE_NO_LINKINFO
Definition: shlobj.h:1952
@ SLDF_RUNAS_USER
Definition: shlobj.h:1959
@ SLDF_UNICODE
Definition: shlobj.h:1951
@ SLDF_HAS_NAME
Definition: shlobj.h:1946
#define EXP_SPECIAL_FOLDER_SIG
Definition: shlobj.h:2054
struct EXP_SPECIAL_FOLDER * LPEXP_SPECIAL_FOLDER
#define PathRemoveBackslash
Definition: shlwapi.h:1049
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
DWORD idSpecialFolder
Definition: shlobj.h:2041
Definition: fci.c:116
uint32_t ULONG
Definition: typedefs.h:59
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define DATE_SHORTDATE
Definition: winnls.h:198

◆ Load() [2/2]

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

Implements IPersistFile.

Definition at line 340 of file CShellLink.cpp.

341{
342 TRACE("(%p, %s, %x)\n", this, debugstr_w(pszFileName), dwMode);
343
344 if (dwMode == 0)
346
349 if (SUCCEEDED(hr))
350 {
353 hr = Load(stm);
355 m_bDirty = FALSE;
356 }
357 TRACE("-- returning hr %08x\n", hr);
358 return hr;
359}
HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
Definition: istream.c:484
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:922
#define STGM_READ
Definition: objbase.h:917
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44

Referenced by Initialize(), and Load().

◆ OnCommand()

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

Definition at line 2928 of file CShellLink.cpp.

2929{
2930 switch (id)
2931 {
2932 case IDC_SHORTCUT_FIND:
2934 return;
2935
2937 {
2938 WCHAR wszPath[MAX_PATH] = L"";
2939
2940 if (m_sIcoPath)
2941 wcscpy(wszPath, m_sIcoPath);
2942 else
2943 FindExecutableW(m_sPath, NULL, wszPath);
2944
2946 if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
2947 {
2948 SetIconLocation(wszPath, IconIndex);
2949 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2950
2951 HICON hIconLarge = CreateShortcutIcon(wszPath, IconIndex);
2952 if (hIconLarge)
2953 {
2954 if (m_hIcon)
2956 m_hIcon = hIconLarge;
2958 }
2959 }
2960 return;
2961 }
2962
2964 {
2966 if (result == 1 || result == 0)
2967 {
2968 if (m_bRunAs != result)
2969 {
2970 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2971 }
2972
2973 m_bRunAs = result;
2974 }
2975 return;
2976 }
2977 }
2978 if (codeNotify == EN_CHANGE || codeNotify == CBN_SELCHANGE)
2979 {
2980 if (!m_bInInit)
2981 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2982 }
2983}
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:362
GLuint64EXT * result
Definition: glext.h:11304
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Definition: shlexec.cpp:1288
EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD dwFlags)
Definition: shlfolder.cpp:443
#define IDC_SHORTCUT_FIND
Definition: shresdef.h:476
#define IDC_SHORTCUT_ADVANCED
Definition: shresdef.h:478
#define IDC_SHORTCUT_ICON
Definition: shresdef.h:460
#define IDC_SHORTCUT_CHANGE_ICON
Definition: shresdef.h:477
#define IDD_SHORTCUT_EXTENDED_PROPERTIES
Definition: shresdef.h:407
UINT_PTR WPARAM
Definition: windef.h:207
#define STM_SETICON
Definition: winuser.h:2095
#define CBN_SELCHANGE
Definition: winuser.h:1982
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI GetParent(_In_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define EN_CHANGE
Definition: winuser.h:2025

◆ OnDestroy()

void CShellLink::OnDestroy ( HWND  hwndDlg)

Definition at line 3053 of file CShellLink.cpp.

3054{
3055 if (m_hIcon)
3056 {
3058 m_hIcon = NULL;
3059 }
3060}

◆ OnInitDialog()

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

Definition at line 2768 of file CShellLink.cpp.

2769{
2770 TRACE("CShellLink::OnInitDialog(hwnd %p hwndFocus %p lParam %p)\n", hwndDlg, hwndFocus, lParam);
2771
2773
2774 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,
2776
2777 m_bInInit = TRUE;
2779
2780 /* Get file information */
2781 // FIXME! FIXME! Shouldn't we use m_sIcoPath, m_Header.nIconIndex instead???
2782 SHFILEINFOW fi;
2783 if (!SHGetFileInfoW(m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_ICON))
2784 {
2785 ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_sLinkPath, GetLastError());
2786 fi.szTypeName[0] = L'\0';
2787 fi.hIcon = NULL;
2788 }
2789
2790 if (fi.hIcon)
2791 {
2792 if (m_hIcon)
2794 m_hIcon = fi.hIcon;
2796 }
2797 else
2798 ERR("ExtractIconW failed %ls %u\n", m_sIcoPath, m_Header.nIconIndex);
2799
2800 if (!SHGetFileInfoW(m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME))
2803
2804 /* Target type */
2805 if (m_sPath)
2806 {
2810 }
2811
2812 /* Target location */
2813 if (m_sPath)
2814 {
2819 }
2820
2821 /* Target path */
2822 if (m_sPath)
2823 {
2824 WCHAR newpath[MAX_PATH * 2];
2825 newpath[0] = UNICODE_NULL;
2826 if (wcschr(m_sPath, ' '))
2827 StringCchPrintfExW(newpath, _countof(newpath), NULL, NULL, 0, L"\"%ls\"", m_sPath);
2828 else
2829 StringCchCopyExW(newpath, _countof(newpath), m_sPath, NULL, NULL, 0);
2830
2831 if (m_sArgs && m_sArgs[0])
2832 {
2833 StringCchCatW(newpath, _countof(newpath), L" ");
2834 StringCchCatW(newpath, _countof(newpath), m_sArgs);
2835 }
2836 SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, newpath);
2837 }
2838
2839 /* Working dir */
2840 if (m_sWorkDir)
2842
2843 /* Description */
2844 if (m_sDescription)
2846
2847 /* Hot key */
2849
2850 /* Run */
2852 const DWORD runshowcmd[] = { SW_SHOWNORMAL, SW_SHOWMINNOACTIVE, SW_SHOWMAXIMIZED };
2853 HWND hRunCombo = GetDlgItem(hwndDlg, IDC_SHORTCUT_RUN_COMBO);
2854 for (UINT i = 0; i < _countof(runstrings); ++i)
2855 {
2857 if (!LoadStringW(shell32_hInstance, runstrings[i], buf, _countof(buf)))
2858 break;
2859
2860 int index = SendMessageW(hRunCombo, CB_ADDSTRING, 0, (LPARAM)buf);
2861 if (index < 0)
2862 continue;
2863 SendMessageW(hRunCombo, CB_SETITEMDATA, index, runshowcmd[i]);
2864 if (!i || m_Header.nShowCommand == runshowcmd[i])
2865 SendMessageW(hRunCombo, CB_SETCURSEL, index, 0);
2866 }
2867
2868 BOOL disablecontrols = FALSE;
2869 if (darwin)
2870 {
2871 disablecontrols = TRUE;
2874 }
2875 else
2876 {
2877 WCHAR path[MAX_PATH * 2];
2878 path[0] = UNICODE_NULL;
2880 if (FAILED(hr))
2881 hr = GetPath(path, _countof(path), NULL, 0);
2882#if DBG
2883 if (GetKeyState(VK_CONTROL) < 0) // Allow inspection of PIDL parsing path
2884 {
2885 hr = S_OK;
2886 path[0] = UNICODE_NULL;
2887 }
2888#endif
2889 if (hr != S_OK)
2890 {
2891 disablecontrols = TRUE;
2892 LPITEMIDLIST pidl;
2893 if (GetIDList(&pidl) == S_OK)
2894 {
2895 path[0] = UNICODE_NULL;
2896 SHGetNameAndFlagsW(pidl, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING, path, _countof(path), NULL);
2899 ILRemoveLastID(pidl);
2900 path[0] = UNICODE_NULL;
2902 SHGetNameAndFlagsW(pidl, SHGDN_NORMAL, path, _countof(path), NULL);
2904 ILFree(pidl);
2905 }
2908 }
2909 else
2910 {
2911 ASSERT(FAILED(hr) || !(path[0] == ':' && path[1] == ':' && path[2] == '{'));
2912 }
2913 }
2914
2915 HWND hWndTarget = GetDlgItem(hwndDlg, IDC_SHORTCUT_TARGET_TEXT);
2916 EnableWindow(hWndTarget, !disablecontrols);
2917 PostMessage(hWndTarget, EM_SETSEL, 0, -1); // Fix caret bug when first opening the tab
2918
2919 /* auto-completion */
2920 SHAutoComplete(hWndTarget, SHACF_DEFAULT);
2922
2923 m_bInInit = FALSE;
2924
2925 return TRUE;
2926}
#define wcschr
Definition: compat.h:17
HRESULT SHGetNameAndFlagsW(_In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_opt_ LPWSTR pszText, _In_ UINT cchBuf, _Inout_opt_ DWORD *pdwAttributes)
Definition: utils.cpp:477
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum target
Definition: glext.h:7315
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ASSERT(a)
Definition: mode.c:44
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:221
#define HKM_SETHOTKEY
Definition: commctrl.h:2236
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:430
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:167
#define SHGFI_ICON
Definition: shellapi.h:165
#define SHGFI_TYPENAME
Definition: shellapi.h:168
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
#define SHACF_DEFAULT
Definition: shlwapi.h:1939
#define IDS_SHORTCUT_RUN_MAX
Definition: shresdef.h:263
#define IDC_SHORTCUT_RUN_COMBO
Definition: shresdef.h:473
#define IDS_SHORTCUT_RUN_MIN
Definition: shresdef.h:262
#define IDC_SHORTCUT_LOCATION_EDIT
Definition: shresdef.h:465
#define IDC_SHORTCUT_TEXT
Definition: shresdef.h:461
#define IDC_SHORTCUT_TARGET_TEXT
Definition: shresdef.h:467
#define IDC_SHORTCUT_KEY_HOTKEY
Definition: shresdef.h:471
#define IDS_SHORTCUT_RUN_NORMAL
Definition: shresdef.h:261
#define IDC_SHORTCUT_TYPE_EDIT
Definition: shresdef.h:463
#define IDC_SHORTCUT_COMMENT_EDIT
Definition: shresdef.h:475
#define IDC_SHORTCUT_START_IN_EDIT
Definition: shresdef.h:469
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
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
WCHAR szTypeName[80]
Definition: shellapi.h:377
WCHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:376
HICON hIcon
Definition: shellapi.h:373
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SW_SHOWMAXIMIZED
Definition: winuser.h:776
#define CB_SETITEMDATA
Definition: winuser.h:1969
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CB_SETCURSEL
Definition: winuser.h:1964
#define VK_CONTROL
Definition: winuser.h:2206
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CB_ADDSTRING
Definition: winuser.h:1939
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define EM_SETSEL
Definition: winuser.h:2021
#define PostMessage
Definition: winuser.h:5844
#define SW_SHOWMINNOACTIVE
Definition: winuser.h:780
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SHORT WINAPI GetKeyState(_In_ int)

◆ OnNotify()

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

Definition at line 2985 of file CShellLink.cpp.

2986{
2987 WCHAR wszBuf[MAX_PATH];
2988 LPPSHNOTIFY lppsn = (LPPSHNOTIFY)pnmhdr;
2989
2990 if (lppsn->hdr.code == PSN_APPLY)
2991 {
2992 /* set working directory */
2993 GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, wszBuf, _countof(wszBuf));
2994 SetWorkingDirectory(wszBuf);
2995
2996 /* set link destination */
2997 GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf));
2998 LPWSTR lpszArgs = NULL;
2999 LPWSTR unquoted = strdupW(wszBuf);
3000 StrTrimW(unquoted, L" ");
3001
3002 if (!PathFileExistsW(unquoted))
3003 {
3004 lpszArgs = PathGetArgsW(unquoted);
3005 PathRemoveArgsW(unquoted);
3006 StrTrimW(lpszArgs, L" ");
3007 }
3008 if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
3009 PathUnquoteSpacesW(unquoted);
3010
3011 WCHAR *pwszExt = PathFindExtensionW(unquoted);
3012 if (!_wcsicmp(pwszExt, L".lnk"))
3013 {
3014 // FIXME load localized error msg
3015 MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR);
3017 return TRUE;
3018 }
3019
3020 if (!PathFileExistsW(unquoted))
3021 {
3022 // FIXME load localized error msg
3023 MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", L"Error", MB_ICONERROR);
3025 return TRUE;
3026 }
3027
3028 SetPath(unquoted);
3029 if (lpszArgs)
3030 SetArguments(lpszArgs);
3031 else
3032 SetArguments(L"\0");
3033
3034 HeapFree(GetProcessHeap(), 0, unquoted);
3035
3037
3039 if (index != CB_ERR)
3040 {
3042 }
3043
3044 TRACE("This %p m_sLinkPath %S\n", this, m_sLinkPath);
3048 return TRUE;
3049 }
3050 return FALSE;
3051}
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
void WINAPI PathRemoveArgsW(LPWSTR lpszPath)
Definition: path.c:779
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1783
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1040
LPWSTR WINAPI PathGetArgsW(LPCWSTR lpszPath)
Definition: path.c:506
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1883
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define PSNRET_INVALID_NOCHANGEPAGE
Definition: prsht.h:131
#define PSN_APPLY
Definition: prsht.h:117
#define PSNRET_NOERROR
Definition: prsht.h:129
struct _PSHNOTIFY * LPPSHNOTIFY
#define HKM_GETHOTKEY
Definition: commctrl.h:2237
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1903
#define SHCNF_PATHW
Definition: shlobj.h:1925
NMHDR hdr
Definition: prsht.h:330
UINT code
Definition: winuser.h:3162
#define SetWindowLongPtr
Definition: treelist.c:70
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define CB_ERR
Definition: winuser.h:2438
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:790
#define CB_GETITEMDATA
Definition: winuser.h:1953
#define DWLP_MSGRESULT
Definition: winuser.h:873
#define CB_GETCURSEL
Definition: winuser.h:1946

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 2542 of file CShellLink.cpp.

2543{
2544 INT id = 0;
2545
2546 m_idCmdFirst = idCmdFirst;
2547
2548 TRACE("%p %p %u %u %u %u\n", this,
2549 hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
2550
2551 if (!hMenu)
2552 return E_INVALIDARG;
2553
2556
2557 MENUITEMINFOW mii;
2558 ZeroMemory(&mii, sizeof(mii));
2559 mii.cbSize = sizeof(mii);
2561 mii.dwTypeData = strOpen.GetBuffer();
2562 mii.cch = wcslen(mii.dwTypeData);
2563 mii.wID = idCmdFirst + id++;
2565 mii.fType = MFT_STRING;
2566 if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2567 return E_FAIL;
2568
2570 mii.dwTypeData = strOpenFileLoc.GetBuffer();
2571 mii.cch = wcslen(mii.dwTypeData);
2572 mii.wID = idCmdFirst + id++;
2573 mii.fState = MFS_ENABLED;
2574 mii.fType = MFT_STRING;
2575 if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2576 return E_FAIL;
2577
2578 UNREFERENCED_PARAMETER(indexMenu);
2579
2580 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, id);
2581}
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define IDS_OPEN_VERB
Definition: shresdef.h:212
#define IDS_OPENFILELOCATION
Definition: shresdef.h:246
LPWSTR dwTypeData
Definition: winuser.h:3272
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define MIIM_ID
Definition: winuser.h:725
#define MIIM_STATE
Definition: winuser.h:724
#define MFS_DEFAULT
Definition: winuser.h:751
#define MFS_ENABLED
Definition: winuser.h:753
#define MFT_STRING
Definition: winuser.h:749
#define MIIM_TYPE
Definition: winuser.h:728
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

◆ RemoveDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::RemoveDataBlock ( DWORD  dwSig)
override

Implements IShellLinkDataList.

Definition at line 2471 of file CShellLink.cpp.

2472{
2473 if (SHRemoveDataBlock(&m_pDBList, dwSig))
2474 {
2475 m_bDirty = TRUE;
2476 return S_OK;
2477 }
2478 return S_FALSE;
2479}
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 
)
override

Definition at line 3120 of file CShellLink.cpp.

3121{
3122 TRACE("(%p) (uPageID %u, pfnReplacePage %p lParam %p\n", this, uPageID, pfnReplacePage, lParam);
3123 return E_NOTIMPL;
3124}

◆ Reset()

VOID CShellLink::Reset ( )
private

Definition at line 236 of file CShellLink.cpp.

Referenced by Load().

◆ Resolve()

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

Implements IShellLinkA.

Definition at line 1445 of file CShellLink.cpp.

1446{
1447 HRESULT hr = S_OK;
1448 BOOL bSuccess;
1449
1450 TRACE("(%p)->(hwnd=%p flags=%x)\n", this, hwnd, fFlags);
1451
1452 /* FIXME: use IResolveShellLink interface? */
1453
1454 // FIXME: See InvokeCommand().
1455
1456#if (NTDDI_VERSION < NTDDI_LONGHORN)
1457 // NOTE: For Logo3 (EXP_LOGO3_ID_SIG), check also for SHRestricted(REST_NOLOGO3CHANNELNOTIFY)
1459 {
1460 FIXME("Logo3 links are not supported yet!\n");
1461 return E_FAIL;
1462 }
1463#endif
1464
1465 /* Resolve Darwin (MSI) target */
1467 {
1468 LPWSTR component = NULL;
1469 hr = GetAdvertiseInfo(&component, EXP_DARWIN_ID_SIG);
1470 if (FAILED(hr))
1471 return E_FAIL;
1472
1473 /* Clear the cached path */
1476 if (!m_sPath)
1477 return E_FAIL;
1478 }
1479
1480 if (!m_sPath && m_pPidl)
1481 {
1483
1485 if (bSuccess && *buffer)
1486 {
1488 if (!m_sPath)
1489 return E_OUTOFMEMORY;
1490
1491 m_bDirty = TRUE;
1492 }
1493 else
1494 {
1495 hr = S_OK; /* don't report an error occurred while just caching information */
1496 }
1497 }
1498
1499 // FIXME: Strange to do that here...
1500 if (!m_sIcoPath && m_sPath)
1501 {
1503 if (!m_sIcoPath)
1504 return E_OUTOFMEMORY;
1505
1506 m_Header.nIconIndex = 0;
1507
1508 m_bDirty = TRUE;
1509 }
1510
1511 return hr;
1512}
static BOOLEAN bSuccess
Definition: drive.cpp:355
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by InvokeCommand(), and OnInitDialog().

◆ Save() [1/2]

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

Implements IPersistStream.

Definition at line 910 of file CShellLink.cpp.

911{
912 TRACE("%p %p %x\n", this, stm, fClearDirty);
913
914 m_Header.dwSize = sizeof(m_Header);
915 m_Header.clsid = CLSID_ShellLink;
916
917 /* Store target attributes */
918 WIN32_FIND_DATAW wfd = {};
919 WCHAR FsTarget[MAX_PATH];
920 if (GetPath(FsTarget, _countof(FsTarget), NULL, 0) == S_OK && PathFileExistsW(FsTarget))
921 {
922 HANDLE hFind = FindFirstFileW(FsTarget, &wfd);
923 if (hFind != INVALID_HANDLE_VALUE)
924 FindClose(hFind);
925 }
926 m_Header.dwFileAttributes = wfd.dwFileAttributes;
927 m_Header.ftCreationTime = wfd.ftCreationTime;
928 m_Header.ftLastAccessTime = wfd.ftLastAccessTime;
929 m_Header.ftLastWriteTime = wfd.ftLastWriteTime;
930 m_Header.nFileSizeLow = wfd.nFileSizeLow;
931
932 /*
933 * Reset the flags: keep only the flags related to data blocks as they were
934 * already set in accordance by the different mutator member functions.
935 * The other flags will be determined now by the presence or absence of data.
936 */
939#if (NTDDI_VERSION < NTDDI_LONGHORN)
941#endif
943 // TODO: When we will support Vista+ functionality, add other flags to this list.
944
945 /* The stored strings are in UNICODE */
947
948 if (m_pPidl)
954 if (m_sPathRel && *m_sPathRel)
956 if (m_sWorkDir && *m_sWorkDir)
958 if (m_sArgs && *m_sArgs)
960 if (m_sIcoPath && *m_sIcoPath)
962 if (m_bRunAs)
964
965 /* Write the shortcut header */
966 ULONG count;
967 HRESULT hr = stm->Write(&m_Header, sizeof(m_Header), &count);
968 if (FAILED(hr))
969 {
970 ERR("Write failed\n");
971 return hr;
972 }
973
974 /* Save the data in order */
975
976 if (m_pPidl)
977 {
978 hr = ILSaveToStream(stm, m_pPidl);
979 if (FAILED(hr))
980 {
981 ERR("Failed to write PIDL\n");
982 return hr;
983 }
984 }
985
987 {
989 if (FAILED(hr))
990 return hr;
991 }
992
994 {
996 if (FAILED(hr))
997 return hr;
998 }
999
1001 {
1003 if (FAILED(hr))
1004 return hr;
1005 }
1006
1008 {
1010 if (FAILED(hr))
1011 return hr;
1012 }
1013
1015 {
1017 if (FAILED(hr))
1018 return hr;
1019 }
1020
1022 {
1024 if (FAILED(hr))
1025 return hr;
1026 }
1027
1028 /*
1029 * Now save the data block list.
1030 *
1031 * NOTE that both advertised Product and Component are already saved
1032 * inside Logo3 and Darwin data blocks in the m_pDBList list, and the
1033 * m_Header.dwFlags is suitably initialized.
1034 */
1036 if (FAILED(hr))
1037 return hr;
1038
1039 /* Clear the dirty bit if requested */
1040 if (fClearDirty)
1041 m_bDirty = FALSE;
1042
1043 return hr;
1044}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
HRESULT WINAPI SHWriteDataBlockList(IStream *lpStream, LPDBLIST lpList)
Definition: clist.c:179
HRESULT Write([in, size_is(cb)] const void *pv, [in] ULONG cb, [out] ULONG *pcbWritten)
HRESULT WINAPI ILSaveToStream(IStream *pStream, LPCITEMIDLIST pPidl)
Definition: pidl.c:353
@ SLDF_RUN_IN_SEPARATE
Definition: shlobj.h:1954
@ SLDF_RUN_WITH_SHIMLAYER
Definition: shlobj.h:1963

◆ Save() [2/2]

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

Implements IPersistFile.

Definition at line 361 of file CShellLink.cpp.

362{
363 BOOL bAlreadyExists;
364 WCHAR szFullPath[MAX_PATH];
365
366 TRACE("(%p)->(%s)\n", this, debugstr_w(pszFileName));
367
368 if (!pszFileName)
369 return E_FAIL;
370
371 bAlreadyExists = PathFileExistsW(pszFileName);
372
375 if (SUCCEEDED(hr))
376 {
377 hr = Save(stm, FALSE);
378
379 if (SUCCEEDED(hr))
380 {
381 GetFullPathNameW(pszFileName, _countof(szFullPath), szFullPath, NULL);
382 if (bAlreadyExists)
384 else
386
387 if (m_sLinkPath)
389
391 m_bDirty = FALSE;
392 }
393 else
394 {
396 WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName));
397 }
398 }
399
400 return hr;
401}
#define WARN(fmt,...)
Definition: precomp.h:61
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
#define STGM_CREATE
Definition: objbase.h:926
#define STGM_READWRITE
Definition: objbase.h:919
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:923
#define SHCNE_CREATE
Definition: shlobj.h:1891

Referenced by OnNotify(), and Save().

◆ SaveCompleted()

HRESULT STDMETHODCALLTYPE CShellLink::SaveCompleted ( LPCOLESTR  pszFileName)
override

Implements IPersistFile.

Definition at line 403 of file CShellLink.cpp.

404{
405 FIXME("(%p)->(%s)\n", this, debugstr_w(pszFileName));
406 return S_OK;
407}

◆ SetAdvertiseInfo()

HRESULT CShellLink::SetAdvertiseInfo ( LPCWSTR  str)
private

Definition at line 2144 of file CShellLink.cpp.

2145{
2146 HRESULT hr;
2147 LPCWSTR szComponent = NULL, szProduct = NULL, p;
2148 INT len;
2149 GUID guid;
2150 WCHAR szGuid[38+1];
2151
2153
2154 while (str[0])
2155 {
2156 /* each segment must start with two colons */
2157 if (str[0] != ':' || str[1] != ':')
2158 return E_FAIL;
2159
2160 /* the last segment is just two colons */
2161 if (!str[2])
2162 break;
2163 str += 2;
2164
2165 /* there must be a colon straight after a guid */
2166 p = wcschr(str, L':');
2167 if (!p)
2168 return E_FAIL;
2169 len = p - str;
2170 if (len != 38)
2171 return E_FAIL;
2172
2173 /* get the guid, and check if it's validly formatted */
2174 memcpy(szGuid, str, sizeof(WCHAR)*len);
2175 szGuid[len] = 0;
2176
2178 if (hr != S_OK)
2179 return hr;
2180 str = p + 1;
2181
2182 /* match it up to a guid that we care about */
2183 if (IsEqualGUID(guid, SHELL32_AdvtShortcutComponent) && !szComponent)
2184 szComponent = str; /* Darwin */
2185 else if (IsEqualGUID(guid, SHELL32_AdvtShortcutProduct) && !szProduct)
2186 szProduct = str; /* Logo3 */
2187 else
2188 return E_FAIL;
2189
2190 /* skip to the next field */
2191 str = wcschr(str, L':');
2192 if (!str)
2193 return E_FAIL;
2194 }
2195
2196 /* we have to have a component for an advertised shortcut */
2197 if (!szComponent)
2198 return E_FAIL;
2199
2200 szComponent = GetAdvertisedArg(szComponent);
2201 szProduct = GetAdvertisedArg(szProduct);
2202
2203 hr = WriteAdvertiseInfo(szComponent, EXP_DARWIN_ID_SIG);
2204 // if (FAILED(hr))
2205 // return hr;
2206#if (NTDDI_VERSION < NTDDI_LONGHORN)
2207 hr = WriteAdvertiseInfo(szProduct, EXP_LOGO3_ID_SIG);
2208 // if (FAILED(hr))
2209 // return hr;
2210#endif
2211
2212 HeapFree(GetProcessHeap(), 0, (PVOID)szComponent);
2213 HeapFree(GetProcessHeap(), 0, (PVOID)szProduct);
2214
2215 if (TRACE_ON(shell))
2216 {
2218 TRACE("Component = %s\n", debugstr_w(sComponent));
2219#if (NTDDI_VERSION < NTDDI_LONGHORN)
2220 GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
2221 TRACE("Product = %s\n", debugstr_w(sProduct));
2222#endif
2223 }
2224
2225 return S_OK;
2226}
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
const GUID SHELL32_AdvtShortcutProduct
const GUID SHELL32_AdvtShortcutComponent
GLfloat GLfloat p
Definition: glext.h:8902
const GUID * guid
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const WCHAR szGuid[]
Definition: rtlstr.c:1892
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by SetPath().

◆ SetArguments() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCSTR  pszArgs)
override

Implements IShellLinkA.

Definition at line 1264 of file CShellLink.cpp.

1265{
1266 TRACE("(%p)->(args=%s)\n", this, pszArgs);
1267
1269 m_sArgs = NULL;
1270
1271 if (pszArgs)
1272 {
1273 m_sArgs = HEAP_strdupAtoW(GetProcessHeap(), 0, pszArgs);
1274 if (!m_sArgs)
1275 return E_OUTOFMEMORY;
1276 }
1277 m_bDirty = TRUE;
1278
1279 return S_OK;
1280}

Referenced by OnNotify().

◆ SetArguments() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCWSTR  pszArgs)
override

Implements IShellLinkW.

Definition at line 1685 of file CShellLink.cpp.

1686{
1687 TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs));
1688
1690 m_sArgs = NULL;
1691
1692 if (pszArgs)
1693 {
1694 m_sArgs = strdupW(pszArgs);
1695 if (!m_sArgs)
1696 return E_OUTOFMEMORY;
1697 }
1698 m_bDirty = TRUE;
1699
1700 return S_OK;
1701}

◆ SetDescription() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCSTR  pszName)
override

Implements IShellLinkA.

Definition at line 1200 of file CShellLink.cpp.

1201{
1202 TRACE("(%p)->(pName=%s)\n", this, pszName);
1203
1206
1207 if (pszName)
1208 {
1210 if (!m_sDescription)
1211 return E_OUTOFMEMORY;
1212 }
1213 m_bDirty = TRUE;
1214
1215 return S_OK;
1216}

◆ SetDescription() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCWSTR  pszName)
override

Implements IShellLinkW.

Definition at line 1623 of file CShellLink.cpp.

1624{
1625 TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
1626
1629
1630 if (pszName)
1631 {
1632 m_sDescription = strdupW(pszName);
1633 if (!m_sDescription)
1634 return E_OUTOFMEMORY;
1635 }
1636 m_bDirty = TRUE;
1637
1638 return S_OK;
1639}

◆ SetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::SetFlags ( DWORD  dwFlags)
override

Implements IShellLinkDataList.

Definition at line 2488 of file CShellLink.cpp.

2489{
2490#if 0 // FIXME!
2492 m_bDirty = TRUE;
2493 return S_OK;
2494#else
2495 FIXME("\n");
2496 return E_NOTIMPL;
2497#endif
2498}
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ SetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::SetHotkey ( WORD  wHotkey)
override

Implements IShellLinkA.

Definition at line 1289 of file CShellLink.cpp.

1290{
1291 TRACE("(%p)->(hotkey=%x)\n", this, wHotkey);
1292
1293 m_Header.wHotKey = wHotkey;
1294 m_bDirty = TRUE;
1295
1296 return S_OK;
1297}

◆ SetIconLocation() [1/2]

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

Definition at line 1386 of file CShellLink.cpp.

1387{
1388 TRACE("(%p)->(path=%s iicon=%u)\n", this, pszIconPath, iIcon);
1389
1390 LPWSTR str = NULL;
1391 if (pszIconPath)
1392 {
1393 str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
1394 if (!str)
1395 return E_OUTOFMEMORY;
1396 }
1397
1398 HRESULT hr = SetIconLocation(str, iIcon);
1399
1400 if (str)
1402
1403 return hr;
1404}

Referenced by OnCommand(), and SetIconLocation().

◆ SetIconLocation() [2/2]

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

Definition at line 1915 of file CShellLink.cpp.

1916{
1917 HRESULT hr = E_FAIL;
1918 WCHAR szIconPath[MAX_PATH];
1919
1920 TRACE("(%p)->(path=%s iicon=%u)\n", this, debugstr_w(pszIconPath), iIcon);
1921
1922 if (pszIconPath)
1923 {
1924 /*
1925 * Check whether the user-given file path contains unexpanded
1926 * environment variables. If so, create a target environment block.
1927 * Note that in this block we will store the user-given path.
1928 * It will contain the unexpanded environment variables, but
1929 * it can also contain already expanded path that the user does
1930 * not want to see them unexpanded (e.g. so that they always
1931 * refer to the same place even if the would-be corresponding
1932 * environment variable could change).
1933 */
1934#ifdef ICON_LINK_WINDOWS_COMPAT
1935 /* Try to fully unexpand the icon path */
1936 // if (PathFullyUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath)))
1937 BOOL bSuccess = PathUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath));
1938 if (bSuccess && wcscmp(pszIconPath, szIconPath) != 0)
1939#else
1940 /*
1941 * In some situations, described in http://stackoverflow.com/questions/2976489/ishelllinkseticonlocation-translates-my-icon-path-into-program-files-which-i
1942 * the result of PathUnExpandEnvStringsW() could be wrong, and instead
1943 * one would have to store the actual provided icon location path, while
1944 * creating an icon environment block ONLY if that path already contains
1945 * environment variables. This is what the present case is trying to implement.
1946 */
1947 SHExpandEnvironmentStringsW(pszIconPath, szIconPath, _countof(szIconPath));
1948 if (wcscmp(pszIconPath, szIconPath) != 0)
1949#endif
1950 {
1951 /*
1952 * The user-given file path contains unexpanded environment
1953 * variables, so we need an icon environment block.
1954 */
1956 LPEXP_SZ_LINK pInfo;
1957
1958#ifdef ICON_LINK_WINDOWS_COMPAT
1959 /* Make pszIconPath point to the unexpanded path */
1960 LPCWSTR pszOrgIconPath = pszIconPath;
1961 pszIconPath = szIconPath;
1962#endif
1964 if (pInfo)
1965 {
1966 /* Make sure that the size of the structure is valid */
1967 if (pInfo->cbSize != sizeof(*pInfo))
1968 {
1969 ERR("Ooops. This structure is not as expected...\n");
1970
1971 /* Invalid structure, remove it altogether */
1972 m_Header.dwFlags &= ~SLDF_HAS_EXP_ICON_SZ;
1974
1975 /* Reset the pointer and go use the static buffer */
1976 pInfo = NULL;
1977 }
1978 }
1979 if (!pInfo)
1980 {
1981 /* Use the static buffer */
1982 pInfo = &buffer;
1983 buffer.cbSize = sizeof(buffer);
1984 buffer.dwSignature = EXP_SZ_ICON_SIG;
1985 }
1986
1987 lstrcpynW(pInfo->szwTarget, pszIconPath, _countof(pInfo->szwTarget));
1988 WideCharToMultiByte(CP_ACP, 0, pszIconPath, -1,
1989 pInfo->szTarget, _countof(pInfo->szTarget), NULL, NULL);
1990
1991 hr = S_OK;
1992 if (pInfo == &buffer)
1993 hr = AddDataBlock(pInfo);
1994 if (hr == S_OK)
1996
1997#ifdef ICON_LINK_WINDOWS_COMPAT
1998 /* Set pszIconPath back to the original one */
1999 pszIconPath = pszOrgIconPath;
2000#else
2001 /* Now, make pszIconPath point to the expanded path */
2002 pszIconPath = szIconPath;
2003#endif
2004 }
2005 else
2006 {
2007 /*
2008 * The user-given file path does not contain unexpanded environment
2009 * variables, so we need to remove any icon environment block.
2010 */
2011 m_Header.dwFlags &= ~SLDF_HAS_EXP_ICON_SZ;
2013
2014 /* pszIconPath points to the user path */
2015 }
2016 }
2017
2018#ifdef ICON_LINK_WINDOWS_COMPAT
2019 /* Store the original icon path location (may contain unexpanded environment strings) */
2020#endif
2021 if (pszIconPath)
2022 {
2023 m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
2025
2026 m_sIcoPath = strdupW(pszIconPath);
2027 if (!m_sIcoPath)
2028 return E_OUTOFMEMORY;
2029
2031 }
2032
2033 hr = S_OK;
2034
2035 m_Header.nIconIndex = iIcon;
2036 m_bDirty = TRUE;
2037
2038 return hr;
2039}
BOOL WINAPI PathUnExpandEnvStringsW(LPCWSTR path, LPWSTR buffer, UINT buf_len)
Definition: path.c:4181
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ SetIDList()

HRESULT STDMETHODCALLTYPE CShellLink::SetIDList ( PCIDLIST_ABSOLUTE  pidl)
override

Implements IShellLinkA.

Definition at line 1180 of file CShellLink.cpp.

1181{
1182 TRACE("(%p)->(pidl=%p)\n", this, pidl);
1183 return SetTargetFromPIDLOrPath(pidl, NULL);
1184}

◆ SetPath() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetPath ( LPCSTR  pszFile)
override

Implements IShellLinkA.

Definition at line 1514 of file CShellLink.cpp.

1515{
1516 TRACE("(%p)->(path=%s)\n", this, pszFile);
1517
1518 if (!pszFile)
1519 return E_INVALIDARG;
1520
1521 LPWSTR str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1522 if (!str)
1523 return E_OUTOFMEMORY;
1524
1525 HRESULT hr = SetPath(str);
1527
1528 return hr;
1529}

Referenced by OnNotify(), and SetPath().

◆ SetPath() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetPath ( LPCWSTR  pszFile)
override

Implements IShellLinkW.

Definition at line 2308 of file CShellLink.cpp.

2309{
2310 LPWSTR unquoted = NULL;
2311 HRESULT hr = S_OK;
2312
2313 TRACE("(%p)->(path=%s)\n", this, debugstr_w(pszFile));
2314
2315 if (!pszFile)
2316 return E_INVALIDARG;
2317
2318 /*
2319 * Allow upgrading Logo3 shortcuts (m_Header.dwFlags & SLDF_HAS_LOGO3ID),
2320 * but forbid upgrading Darwin ones.
2321 */
2323 return S_FALSE;
2324
2325 /* quotes at the ends of the string are stripped */
2326 SIZE_T len = wcslen(pszFile);
2327 if (pszFile[0] == L'"' && pszFile[len-1] == L'"')
2328 {
2329 unquoted = strdupW(pszFile);
2330 PathUnquoteSpacesW(unquoted);
2331 pszFile = unquoted;
2332 }
2333
2334 /* any other quote marks are invalid */
2335 if (wcschr(pszFile, L'"'))
2336 {
2337 hr = S_FALSE;
2338 goto end;
2339 }
2340
2341 /* Clear the cached path */
2343 m_sPath = NULL;
2344
2345 /* Check for an advertised target (Logo3 or Darwin) */
2346 if (SetAdvertiseInfo(pszFile) != S_OK)
2347 {
2348 /* This is not an advertised target, but a regular path */
2350
2351 /*
2352 * Check whether the user-given file path contains unexpanded
2353 * environment variables. If so, create a target environment block.
2354 * Note that in this block we will store the user-given path.
2355 * It will contain the unexpanded environment variables, but
2356 * it can also contain already expanded path that the user does
2357 * not want to see them unexpanded (e.g. so that they always
2358 * refer to the same place even if the would-be corresponding
2359 * environment variable could change).
2360 */
2361 if (*pszFile)
2363 else
2364 *szPath = L'\0';
2365
2366 if (*pszFile && (wcscmp(pszFile, szPath) != 0))
2367 {
2368 /*
2369 * The user-given file path contains unexpanded environment
2370 * variables, so we need a target environment block.
2371 */
2373 LPEXP_SZ_LINK pInfo;
2374
2376 if (pInfo)
2377 {
2378 /* Make sure that the size of the structure is valid */
2379 if (pInfo->cbSize != sizeof(*pInfo))
2380 {
2381 ERR("Ooops. This structure is not as expected...\n");
2382
2383 /* Invalid structure, remove it altogether */
2384 m_Header.dwFlags &= ~SLDF_HAS_EXP_SZ;
2386
2387 /* Reset the pointer and go use the static buffer */
2388 pInfo = NULL;
2389 }
2390 }
2391 if (!pInfo)
2392 {
2393 /* Use the static buffer */
2394 pInfo = &buffer;
2395 buffer.cbSize = sizeof(buffer);
2396 buffer.dwSignature = EXP_SZ_LINK_SIG;
2397 }
2398
2399 lstrcpynW(pInfo->szwTarget, pszFile, _countof(pInfo->szwTarget));
2400 WideCharToMultiByte(CP_ACP, 0, pszFile, -1,
2401 pInfo->szTarget, _countof(pInfo->szTarget), NULL, NULL);
2402
2403 hr = S_OK;
2404 if (pInfo == &buffer)
2405 hr = AddDataBlock(pInfo);
2406 if (hr == S_OK)
2408
2409 /* Now, make pszFile point to the expanded path */
2410 pszFile = szPath;
2411 }
2412 else
2413 {
2414 /*
2415 * The user-given file path does not contain unexpanded environment
2416 * variables, so we need to remove any target environment block.
2417 */
2418 m_Header.dwFlags &= ~SLDF_HAS_EXP_SZ;
2420
2421 /* pszFile points to the user path */
2422 }
2423
2424 /* Set the target */
2425 hr = SetTargetFromPIDLOrPath(NULL, pszFile);
2426 }
2427
2428 m_bDirty = TRUE;
2429
2430end:
2431 HeapFree(GetProcessHeap(), 0, unquoted);
2432 return hr;
2433}
GLuint GLuint end
Definition: gl.h:1545
ULONG_PTR SIZE_T
Definition: typedefs.h:80

◆ SetRelativePath() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetRelativePath ( LPCSTR  pszPathRel,
DWORD  dwReserved 
)
override

Implements IShellLinkA.

Definition at line 1406 of file CShellLink.cpp.

1407{
1408 TRACE("(%p)->(path=%s %x)\n", this, pszPathRel, dwReserved);
1409
1411 m_sPathRel = NULL;
1412
1413 if (pszPathRel)
1414 {
1415 m_sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
1416 m_bDirty = TRUE;
1417 }
1418
1420}
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95

◆ SetRelativePath() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetRelativePath ( LPCWSTR  pszPathRel,
DWORD  dwReserved 
)
override

Implements IShellLinkW.

Definition at line 2041 of file CShellLink.cpp.

2042{
2043 TRACE("(%p)->(path=%s %x)\n", this, debugstr_w(pszPathRel), dwReserved);
2044
2046 m_sPathRel = NULL;
2047
2048 if (pszPathRel)
2049 {
2050 m_sPathRel = strdupW(pszPathRel);
2051 if (!m_sPathRel)
2052 return E_OUTOFMEMORY;
2053 }
2054 m_bDirty = TRUE;
2055
2057}

◆ SetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::SetShowCmd ( INT  iShowCmd)
override

Definition at line 1306 of file CShellLink.cpp.

1307{
1308 TRACE("(%p) %d\n", this, iShowCmd);
1309
1310 m_Header.nShowCommand = iShowCmd;
1311 m_bDirty = TRUE;
1312
1313 return S_OK;
1314}

◆ SetSite()

HRESULT STDMETHODCALLTYPE CShellLink::SetSite ( IUnknown punk)
override

Implements IObjectWithSite.

Definition at line 3126 of file CShellLink.cpp.

3127{
3128 TRACE("%p %p\n", this, punk);
3129
3130 m_site = punk;
3131
3132 return S_OK;
3133}

◆ SetTargetFromPIDLOrPath()

HRESULT CShellLink::SetTargetFromPIDLOrPath ( LPCITEMIDLIST  pidl,
LPCWSTR  pszFile 
)
private

Definition at line 2228 of file CShellLink.cpp.

2229{
2230 HRESULT hr = S_OK;
2231 LPITEMIDLIST pidlNew = NULL;
2233
2234 /*
2235 * Not both 'pidl' and 'pszFile' should be set.
2236 * But either one or both can be NULL.
2237 */
2238 if (pidl && pszFile)
2239 return E_FAIL;
2240
2241 if (pidl)
2242 {
2243 /* Clone the PIDL */
2244 pidlNew = ILClone(pidl);
2245 if (!pidlNew)
2246 return E_FAIL;
2247 }
2248 else if (pszFile)
2249 {
2250 /* Build a PIDL for this path target */
2251 hr = SHILCreateFromPathW(pszFile, &pidlNew, NULL);
2252 if (FAILED(hr))
2253 {
2254 /* This failed, try to resolve the path, then create a simple PIDL */
2255
2258
2260 {
2261 hr = E_INVALIDARG;
2262 szPath[0] = 0;
2263 }
2264 else
2265 {
2266 hr = S_OK;
2268 // NOTE: Don't make it failed here even if pidlNew was NULL.
2269 // We don't fail on purpose even if SHSimpleIDListFromPathW returns NULL.
2270 // This behaviour has been verified with tests.
2271 }
2272 }
2273 }
2274 // else if (!pidl && !pszFile) { pidlNew = NULL; hr = S_OK; }
2275
2276 ILFree(m_pPidl);
2277 m_pPidl = pidlNew;
2278
2279 if (!pszFile)
2280 {
2281 if (SHGetPathFromIDListW(pidlNew, szPath))
2282 pszFile = szPath;
2283 }
2284
2285 // TODO: Fully update link info, tracker, file attribs...
2286
2287 // if (pszFile)
2288 if (!pszFile)
2289 {
2290 *szPath = L'\0';
2291 pszFile = szPath;
2292 }
2293
2294 /* Update the cached path (for link info) */
2296
2297 if (m_sPath)
2299
2300 m_sPath = strdupW(pszFile);
2301 if (!m_sPath)
2302 return E_OUTOFMEMORY;
2303
2304 m_bDirty = TRUE;
2305 return hr;
2306}
#define PRF_TRYPROGRAMEXTENSIONS
Definition: PathResolve.cpp:40
BOOL WINAPI PathResolveW(_Inout_ LPWSTR path, _Inout_opt_ LPCWSTR *dirs, _In_ DWORD flags)
Definition: shellpath.c:883
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2139
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:403
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
Definition: pidl.c:1238

Referenced by SetIDList(), and SetPath().

◆ SetWorkingDirectory() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory ( LPCSTR  pszDir)
override

Implements IShellLinkA.

Definition at line 1232 of file CShellLink.cpp.

1233{
1234 TRACE("(%p)->(dir=%s)\n", this, pszDir);
1235
1237 m_sWorkDir = NULL;
1238
1239 if (pszDir)
1240 {
1242 if (!m_sWorkDir)
1243 return E_OUTOFMEMORY;
1244 }
1245 m_bDirty = TRUE;
1246
1247 return S_OK;
1248}

Referenced by OnNotify().

◆ SetWorkingDirectory() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory ( LPCWSTR  pszDir)
override

Implements IShellLinkW.

Definition at line 1654 of file CShellLink.cpp.

1655{
1656 TRACE("(%p)->(dir=%s)\n", this, debugstr_w(pszDir));
1657
1659 m_sWorkDir = NULL;
1660
1661 if (pszDir)
1662 {
1664 if (!m_sWorkDir)
1665 return E_OUTOFMEMORY;
1666 }
1667 m_bDirty = TRUE;
1668
1669 return S_OK;
1670}

◆ SH_ShellLinkDlgProc()

INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 3069 of file CShellLink.cpp.

3070{
3071 LPPROPSHEETPAGEW ppsp;
3072 CShellLink *pThis = reinterpret_cast<CShellLink *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
3073
3074 switch (uMsg)
3075 {
3076 case WM_INITDIALOG:
3077 ppsp = (LPPROPSHEETPAGEW)lParam;
3078 if (ppsp == NULL)
3079 break;
3080
3081 pThis = reinterpret_cast<CShellLink *>(ppsp->lParam);
3082 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pThis);
3083 return pThis->OnInitDialog(hwndDlg, (HWND)(wParam), lParam);
3084
3085 case WM_NOTIFY:
3086 return pThis->OnNotify(hwndDlg, (int)wParam, (NMHDR *)lParam);
3087
3088 case WM_COMMAND:
3089 pThis->OnCommand(hwndDlg, LOWORD(wParam), (HWND)lParam, HIWORD(wParam));
3090 break;
3091
3092 case WM_DESTROY:
3093 pThis->OnDestroy(hwndDlg);
3094 break;
3095
3096 default:
3097 break;
3098 }
3099
3100 return FALSE;
3101}
WPARAM wParam
Definition: combotst.c:138
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
struct _PROPSHEETPAGEW * LPPROPSHEETPAGEW
#define WM_NOTIFY
Definition: richedit.h:61
LPARAM lParam
Definition: prsht.h:227
#define GetWindowLongPtr
Definition: treelist.c:73
#define DWLP_USER
Definition: winuser.h:875
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
#define WM_DESTROY
Definition: winuser.h:1612

Referenced by AddPages().

◆ WriteAdvertiseInfo()

HRESULT CShellLink::WriteAdvertiseInfo ( LPCWSTR  string,
DWORD  dwSig 
)
private

Definition at line 2078 of file CShellLink.cpp.

2079{
2081 LPEXP_DARWIN_LINK pInfo;
2082
2083 if ( (dwSig != EXP_DARWIN_ID_SIG)
2085 && (dwSig != EXP_LOGO3_ID_SIG)
2086#endif
2087 )
2088 {
2089 return E_INVALIDARG;
2090 }
2091
2092 if (!string)
2093 return S_FALSE;
2094
2096 if (pInfo)
2097 {
2098 /* Make sure that the size of the structure is valid */
2099 if (pInfo->dbh.cbSize != sizeof(*pInfo))
2100 {
2101 ERR("Ooops. This structure is not as expected...\n");
2102
2103 /* Invalid structure, remove it altogether */
2104 if (dwSig == EXP_DARWIN_ID_SIG)
2105 m_Header.dwFlags &= ~SLDF_HAS_DARWINID;
2106#if (NTDDI_VERSION < NTDDI_LONGHORN)
2107 else if (dwSig == EXP_LOGO3_ID_SIG)
2108 m_Header.dwFlags &= ~SLDF_HAS_LOGO3ID;
2109#endif
2110 RemoveDataBlock(dwSig);
2111
2112 /* Reset the pointer and go use the static buffer */
2113 pInfo = NULL;
2114 }
2115 }
2116 if (!pInfo)
2117 {
2118 /* Use the static buffer */
2119 pInfo = &buffer;
2120 buffer.dbh.cbSize = sizeof(buffer);
2121 buffer.dbh.dwSignature = dwSig;
2122 }
2123
2124 lstrcpynW(pInfo->szwDarwinID, string, _countof(pInfo->szwDarwinID));
2125 WideCharToMultiByte(CP_ACP, 0, string, -1,
2126 pInfo->szDarwinID, _countof(pInfo->szDarwinID), NULL, NULL);
2127
2128 HRESULT hr = S_OK;
2129 if (pInfo == &buffer)
2130 hr = AddDataBlock(pInfo);
2131 if (hr == S_OK)
2132 {
2133 if (dwSig == EXP_DARWIN_ID_SIG)
2135#if (NTDDI_VERSION < NTDDI_LONGHORN)
2136 else if (dwSig == EXP_LOGO3_ID_SIG)
2138#endif
2139 }
2140
2141 return hr;
2142}
#define NTDDI_VERSION
Definition: k32.h:33
#define NTDDI_LONGHORN
Definition: sdkddkver.h:102

Referenced by SetAdvertiseInfo().

Member Data Documentation

◆ m_bDirty

◆ m_bInInit

BOOL CShellLink::m_bInInit
private

Definition at line 88 of file CShellLink.h.

Referenced by CShellLink(), OnCommand(), and OnInitDialog().

◆ m_bRunAs

BOOL CShellLink::m_bRunAs
private

Definition at line 85 of file CShellLink.h.

Referenced by CShellLink(), Load(), OnCommand(), Reset(), and Save().

◆ m_DropTarget

CComPtr<IDropTarget> CShellLink::m_DropTarget
private

Definition at line 99 of file CShellLink.h.

Referenced by DragEnter(), DragLeave(), DragOver(), and Drop().

◆ m_Header

◆ m_hIcon

HICON CShellLink::m_hIcon
private

Definition at line 89 of file CShellLink.h.

Referenced by CShellLink(), OnCommand(), OnDestroy(), and OnInitDialog().

◆ m_idCmdFirst

UINT CShellLink::m_idCmdFirst
private

Definition at line 90 of file CShellLink.h.

Referenced by CShellLink(), and QueryContextMenu().

◆ m_pDBList

◆ m_pPidl

◆ m_sArgs

LPWSTR CShellLink::m_sArgs
private

◆ m_sDescription

LPWSTR CShellLink::m_sDescription
private

◆ m_sIcoPath

LPWSTR CShellLink::m_sIcoPath
private

Definition at line 84 of file CShellLink.h.

Referenced by CShellLink(), GetIconLocation(),