ReactOS 0.4.16-dev-252-g9ccafe8
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 250 of file CShellLink.cpp.

251{
252 m_Header.dwSize = sizeof(m_Header);
253 m_Header.clsid = CLSID_ShellLink;
254 m_Header.dwFlags = 0;
255
261
264 m_Header.wHotKey = 0;
265
266 m_pPidl = NULL;
267
268 m_sPath = NULL;
269 ZeroMemory(&volume, sizeof(volume));
270
274 m_sArgs = NULL;
276 m_bRunAs = FALSE;
277 m_bDirty = FALSE;
278 m_pDBList = NULL;
280 m_hIcon = NULL;
281 m_idCmdFirst = 0;
282
284
286}
#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 288 of file CShellLink.cpp.

289{
290 TRACE("-- destroying IShellLink(%p)\n", this);
291
293
295
303}
#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:946
#define TRACE(s)
Definition: solgame.cpp:4

Member Function Documentation

◆ AddDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::AddDataBlock ( void pDataBlock)
override

Implements IShellLinkDataList.

Definition at line 2427 of file CShellLink.cpp.

2428{
2429 if (SHAddDataBlock(&m_pDBList, (DATABLOCK_HEADER*)pDataBlock))
2430 {
2431 m_bDirty = TRUE;
2432 return S_OK;
2433 }
2434 return S_FALSE;
2435}
#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 3096 of file CShellLink.cpp.

3097{
3099 if (hPage == NULL)
3100 {
3101 ERR("failed to create property sheet page\n");
3102 return E_FAIL;
3103 }
3104
3105 if (!pfnAddPage(hPage, lParam))
3106 return E_FAIL;
3107
3108 return S_OK;
3109}
#define ERR(fmt,...)
Definition: precomp.h:57
LPARAM lParam
Definition: combotst.c:139
#define E_FAIL
Definition: ddrawi.h:102
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define IDD_SHORTCUT_PROPERTIES
Definition: shresdef.h:401
LONG_PTR LPARAM
Definition: windef.h:208

◆ CopyDataBlock()

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

Implements IShellLinkDataList.

Definition at line 2437 of file CShellLink.cpp.

2438{
2439 DATABLOCK_HEADER* pBlock;
2440 PVOID pDataBlock;
2441
2442 TRACE("%p %08x %p\n", this, dwSig, ppDataBlock);
2443
2444 *ppDataBlock = NULL;
2445
2446 pBlock = SHFindDataBlock(m_pDBList, dwSig);
2447 if (!pBlock)
2448 {
2449 ERR("unknown datablock %08x (not found)\n", dwSig);
2450 return E_FAIL;
2451 }
2452
2453 pDataBlock = LocalAlloc(LMEM_ZEROINIT, pBlock->cbSize);
2454 if (!pDataBlock)
2455 return E_OUTOFMEMORY;
2456
2457 CopyMemory(pDataBlock, pBlock, pBlock->cbSize);
2458
2459 *ppDataBlock = pDataBlock;
2460 return S_OK;
2461}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
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 3224 of file CShellLink.cpp.

3225{
3227 const COLORREF crMask = GetSysColor(COLOR_3DFACE);
3228 WCHAR wszLnkIcon[MAX_PATH];
3229 int lnk_idx;
3230 HDC hDC;
3232 HICON hIcon = NULL, hNewIcon = NULL, hShortcut;
3233
3234 if (HLM_GetIconW(IDI_SHELL_SHORTCUT - 1, wszLnkIcon, _countof(wszLnkIcon), &lnk_idx))
3235 {
3236 ::ExtractIconExW(wszLnkIcon, lnk_idx, &hShortcut, NULL, 1);
3237 }
3238 else
3239 {
3241 IMAGE_ICON, cx, cy, 0);
3242 }
3243
3244 ::ExtractIconExW(wszIconPath, IconIndex, &hIcon, NULL, 1);
3245 if (!hIcon || !hShortcut || !himl)
3246 goto cleanup;
3247
3249 if (hDC)
3250 {
3251 // create 32bpp bitmap
3252 BITMAPINFO bi;
3253 ZeroMemory(&bi, sizeof(bi));
3254 bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3255 bi.bmiHeader.biWidth = cx;
3256 bi.bmiHeader.biHeight = cy;
3257 bi.bmiHeader.biPlanes = 1;
3258 bi.bmiHeader.biBitCount = 32;
3259 LPVOID pvBits;
3260 HBITMAP hbm = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
3261 if (hbm)
3262 {
3263 // draw the icon image
3264 HGDIOBJ hbmOld = SelectObject(hDC, hbm);
3265 {
3266 HBRUSH hbr = CreateSolidBrush(crMask);
3267 RECT rc = { 0, 0, cx, cy };
3268 FillRect(hDC, &rc, hbr);
3269 DeleteObject(hbr);
3270
3271 DrawIconEx(hDC, 0, 0, hIcon, cx, cy, 0, NULL, DI_NORMAL);
3272 DrawIconEx(hDC, 0, 0, hShortcut, cx, cy, 0, NULL, DI_NORMAL);
3273 }
3274 SelectObject(hDC, hbmOld);
3275
3276 INT iAdded = ImageList_AddMasked(himl, hbm, crMask);
3277 hNewIcon = ImageList_GetIcon(himl, iAdded, ILD_NORMAL | ILD_TRANSPARENT);
3278
3280 }
3281 DeleteDC(hDC);
3282 }
3283
3284cleanup:
3285 if (hIcon)
3287 if (hShortcut)
3288 DestroyIcon(hShortcut);
3289 if (himl)
3291
3292 return hNewIcon;
3293}
static HDC hDC
Definition: 3dtext.c:33
#define shell32_hInstance
HIMAGELIST himl
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
HICON WINAPI ImageList_GetIcon(HIMAGELIST himl, INT i, UINT fStyle)
Definition: imagelist.c:1963
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#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:849
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:2255
#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:2080
#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:2105
#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 2624 of file CShellLink.cpp.

2625{
2627 const BOOL unicode = IsUnicode(*lpici);
2628
2629 CStringW args;
2630 if (m_sArgs)
2631 args = m_sArgs;
2632
2633 if (unicode)
2634 {
2635 if (!StrIsNullOrEmpty(iciex->lpParametersW))
2636 {
2637 args += L' ';
2638 args += iciex->lpParametersW;
2639 }
2640 }
2641 else
2642 {
2643 CComHeapPtr<WCHAR> pszParams;
2644 if (!StrIsNullOrEmpty(lpici->lpParameters) && __SHCloneStrAtoW(&pszParams, lpici->lpParameters))
2645 {
2646 args += L' ';
2647 args += pszParams;
2648 }
2649 }
2650
2652 SHELLEXECUTEINFOW sei = { sizeof(sei) };
2655 sei.lpDirectory = m_sWorkDir;
2656 if (m_pPidl)
2657 {
2658 sei.lpIDList = m_pPidl;
2660 }
2661 else
2662 {
2663 sei.lpFile = m_sPath;
2665 {
2666 sei.fMask &= ~SEE_MASK_DOENVSUBST; // The link does not want to expand lpFile
2668 sei.lpDirectory = dir;
2669 }
2670 }
2671 sei.lpParameters = args;
2672 sei.lpClass = m_sLinkPath;
2674 if (lpici->nShow != SW_SHOWNORMAL && lpici->nShow != SW_SHOW)
2675 sei.nShow = lpici->nShow; // Allow invoker to override .lnk show mode
2676
2677 // Use the invoker specified working directory if the link did not specify one
2678 if (StrIsNullOrEmpty(sei.lpDirectory) || !PathIsDirectoryW(sei.lpDirectory))
2679 {
2680 LPCSTR pszDirA = lpici->lpDirectory;
2681 if (unicode && !StrIsNullOrEmpty(iciex->lpDirectoryW))
2682 sei.lpDirectory = iciex->lpDirectoryW;
2683 else if (pszDirA && SHAnsiToUnicode(pszDirA, dir, _countof(dir)))
2684 sei.lpDirectory = dir;
2685 }
2686 return (ShellExecuteExW(&sei) ? S_OK : E_FAIL);
2687}
unsigned int dir
Definition: maze.c:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2667
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:168
#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:2434
@ SLDF_HAS_EXP_SZ
Definition: shlobj.h:1953
LPCWSTR lpDirectory
Definition: shellapi.h:334
LPCWSTR lpParameters
Definition: shellapi.h:333
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 2575 of file CShellLink.cpp.

2576{
2577 WCHAR szParams[MAX_PATH + 64];
2578 StringCbPrintfW(szParams, sizeof(szParams), L"/select,%s", m_sPath);
2579
2580 INT_PTR ret;
2581 ret = reinterpret_cast<INT_PTR>(ShellExecuteW(NULL, NULL, L"explorer.exe", szParams,
2583 if (ret <= 32)
2584 {
2585 ERR("ret: %08lX\n", ret);
2586 return E_FAIL;
2587 }
2588
2589 return S_OK;
2590}
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2492
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 3136 of file CShellLink.cpp.

3138{
3139 TRACE("(%p)->(DataObject=%p)\n", this, pDataObject);
3140
3141 if (*pdwEffect == DROPEFFECT_NONE)
3142 return S_OK;
3143
3144 LPCITEMIDLIST pidlLast;
3146
3148
3149 if (SUCCEEDED(hr))
3150 {
3151 hr = psf->GetUIObjectOf(0, 1, &pidlLast, IID_NULL_PPV_ARG(IDropTarget, &m_DropTarget));
3152
3153 if (SUCCEEDED(hr))
3154 hr = m_DropTarget->DragEnter(pDataObject, dwKeyState, pt, pdwEffect);
3155 else
3156 *pdwEffect = DROPEFFECT_NONE;
3157 }
3158 else
3159 *pdwEffect = DROPEFFECT_NONE;
3160
3161 return S_OK;
3162}
#define pt(x, y)
Definition: drawing.c:79
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1356
HRESULT hr
Definition: shlfolder.c:183
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define IID_PPV_ARG(Itype, ppType)
#define IID_NULL_PPV_ARG(Itype, ppType)

◆ DragLeave()

HRESULT STDMETHODCALLTYPE CShellLink::DragLeave ( void  )
override

Implements IDropTarget.

Definition at line 3174 of file CShellLink.cpp.

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

◆ DragOver()

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

Implements IDropTarget.

Definition at line 3164 of file CShellLink.cpp.

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

◆ Drop()

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

Implements IDropTarget.

Definition at line 3187 of file CShellLink.cpp.

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

◆ Extract() [1/2]

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

Implements IExtractIconA.

Definition at line 1350 of file CShellLink.cpp.

1351{
1352 TRACE("(%p)->(path=%s iicon=%u)\n", this, pszFile, nIconIndex);
1353
1354 LPWSTR str = NULL;
1355 if (pszFile)
1356 {
1357 str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1358 if (!str)
1359 return E_OUTOFMEMORY;
1360 }
1361
1362 HRESULT hr = Extract(str, nIconIndex, phiconLarge, phiconSmall, nIconSize);
1363
1364 if (str)
1366
1367 return hr;
1368}
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 1792 of file CShellLink.cpp.

1793{
1794 HRESULT hr = NOERROR;
1795 UINT cxyLarge = LOWORD(nIconSize), cxySmall = HIWORD(nIconSize);
1796
1797 if (phiconLarge)
1798 {
1799 *phiconLarge = NULL;
1800 PrivateExtractIconsW(pszFile, nIconIndex, cxyLarge, cxyLarge, phiconLarge, NULL, 1, 0);
1801
1802 if (*phiconLarge == NULL)
1803 hr = S_FALSE;
1804 }
1805
1806 if (phiconSmall)
1807 {
1808 *phiconSmall = NULL;
1809 PrivateExtractIconsW(pszFile, nIconIndex, cxySmall, cxySmall, phiconSmall, NULL, 1, 0);
1810
1811 if (*phiconSmall == NULL)
1812 hr = S_FALSE;
1813 }
1814
1815 if (hr == S_FALSE)
1816 {
1817 if (phiconLarge && *phiconLarge)
1818 {
1819 DestroyIcon(*phiconLarge);
1820 *phiconLarge = NULL;
1821 }
1822 if (phiconSmall && *phiconSmall)
1823 {
1824 DestroyIcon(*phiconSmall);
1825 *phiconSmall = NULL;
1826 }
1827 }
1828
1829 return hr;
1830}
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 605 of file CShellLink.cpp.

606{
607 LPEXP_DARWIN_LINK pInfo;
608
609 *str = NULL;
610
612 if (!pInfo)
613 return E_FAIL;
614
615 /* Make sure that the size of the structure is valid */
616 if (pInfo->dbh.cbSize != sizeof(*pInfo))
617 {
618 ERR("Ooops. This structure is not as expected...\n");
619 return E_FAIL;
620 }
621
622 TRACE("dwSig %08x string = '%s'\n", pInfo->dbh.dwSignature, debugstr_w(pInfo->szwDarwinID));
623
624 *str = pInfo->szwDarwinID;
625 return S_OK;
626}
#define 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 1234 of file CShellLink.cpp.

1235{
1236 TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1237
1238 if (cchMaxPath)
1239 *pszArgs = 0;
1240
1241 if (m_sArgs)
1243 pszArgs, cchMaxPath, NULL, NULL);
1244
1245 return S_OK;
1246}
#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 1656 of file CShellLink.cpp.

1657{
1658 TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1659
1660 if (cchMaxPath)
1661 *pszArgs = 0;
1662
1663 if (m_sArgs)
1664 lstrcpynW(pszArgs, m_sArgs, cchMaxPath);
1665
1666 return S_OK;
1667}
#define lstrcpynW
Definition: compat.h:738

◆ GetClassID()

HRESULT STDMETHODCALLTYPE CShellLink::GetClassID ( CLSID pclsid)
override

Implements IPersist.

Definition at line 305 of file CShellLink.cpp.

306{
307 TRACE("%p %p\n", this, pclsid);
308
309 if (pclsid == NULL)
310 return E_POINTER;
311 *pclsid = CLSID_ShellLink;
312 return S_OK;
313}
#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 2689 of file CShellLink.cpp.

2690{
2691 FIXME("%p %lu %u %p %p %u\n", this, idCmd, uType, pwReserved, pszName, cchMax);
2692 return E_NOTIMPL;
2693}
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 393 of file CShellLink.cpp.

394{
395 *ppszFileName = NULL;
396
397 if (!m_sLinkPath)
398 {
399 /* IPersistFile::GetCurFile called before IPersistFile::Save */
400 return S_FALSE;
401 }
402
403 *ppszFileName = (LPOLESTR)CoTaskMemAlloc((wcslen(m_sLinkPath) + 1) * sizeof(WCHAR));
404 if (!*ppszFileName)
405 {
406 /* out of memory */
407 return E_OUTOFMEMORY;
408 }
409
410 /* copy last saved filename */
411 wcscpy(*ppszFileName, m_sLinkPath);
412
413 return S_OK;
414}
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
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)

◆ GetDescription() [1/2]

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

Definition at line 1170 of file CShellLink.cpp.

1171{
1172 TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1173
1174 if (cchMaxName)
1175 *pszName = 0;
1176
1177 if (m_sDescription)
1179 pszName, cchMaxName, NULL, NULL);
1180
1181 return S_OK;
1182}

◆ GetDescription() [2/2]

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

Definition at line 1596 of file CShellLink.cpp.

1597{
1598 TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1599
1600 *pszName = 0;
1601 if (m_sDescription)
1602 lstrcpynW(pszName, m_sDescription, cchMaxName);
1603
1604 return S_OK;
1605}

◆ GetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::GetFlags ( DWORD pdwFlags)
override

Implements IShellLinkDataList.

Definition at line 2473 of file CShellLink.cpp.

2474{
2475 TRACE("%p %p\n", this, pdwFlags);
2476 *pdwFlags = m_Header.dwFlags;
2477 return S_OK;
2478}

◆ GetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::GetHotkey ( WORD pwHotkey)
override

Implements IShellLinkA.

Definition at line 1266 of file CShellLink.cpp.

1267{
1268 TRACE("(%p)->(%p)(0x%08x)\n", this, pwHotkey, m_Header.wHotKey);
1269 *pwHotkey = m_Header.wHotKey;
1270 return S_OK;
1271}

◆ GetIconLocation() [1/4]

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

Definition at line 1300 of file CShellLink.cpp.

1301{
1302 HRESULT hr;
1303 LPWSTR pszIconPathW;
1304
1305 TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1306
1307 /* Allocate a temporary UNICODE buffer */
1308 pszIconPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchIconPath * sizeof(WCHAR));
1309 if (!pszIconPathW)
1310 return E_OUTOFMEMORY;
1311
1312 /* Call the UNICODE function */
1313 hr = GetIconLocation(pszIconPathW, cchIconPath, piIcon);
1314
1315 /* Convert the file path back to ANSI */
1316 WideCharToMultiByte(CP_ACP, 0, pszIconPathW, -1,
1317 pszIconPath, cchIconPath, NULL, NULL);
1318
1319 /* Free the temporary buffer */
1320 HeapFree(GetProcessHeap(), 0, pszIconPathW);
1321
1322 return hr;
1323}
#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 1687 of file CShellLink.cpp.

1688{
1689 TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1690
1691 if (cchIconPath)
1692 *pszIconPath = 0;
1693
1694 *piIcon = 0;
1695
1696 /* Update the original icon path location */
1698 {
1700
1701 /* Search for an icon environment block */
1702 LPEXP_SZ_LINK pInfo;
1704 if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1705 {
1707
1708 m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
1710
1712 if (!m_sIcoPath)
1713 return E_OUTOFMEMORY;
1714
1716
1717 m_bDirty = TRUE;
1718 }
1719 }
1720
1721 *piIcon = m_Header.nIconIndex;
1722
1723 if (m_sIcoPath)
1724 lstrcpynW(pszIconPath, m_sIcoPath, cchIconPath);
1725
1726 return S_OK;
1727}
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 1325 of file CShellLink.cpp.

1326{
1327 HRESULT hr;
1328 LPWSTR pszIconFileW;
1329
1330 TRACE("(%p)->(%u %p len=%u piIndex=%p pwFlags=%p)\n", this, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1331
1332 /* Allocate a temporary UNICODE buffer */
1333 pszIconFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR));
1334 if (!pszIconFileW)
1335 return E_OUTOFMEMORY;
1336
1337 /* Call the UNICODE function */
1338 hr = GetIconLocation(uFlags, pszIconFileW, cchMax, piIndex, pwFlags);
1339
1340 /* Convert the file path back to ANSI */
1341 WideCharToMultiByte(CP_ACP, 0, pszIconFileW, -1,
1342 pszIconFile, cchMax, NULL, NULL);
1343
1344 /* Free the temporary buffer */
1345 HeapFree(GetProcessHeap(), 0, pszIconFileW);
1346
1347 return hr;
1348}
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 1751 of file CShellLink.cpp.

1752{
1753 HRESULT hr;
1754
1755 pszIconFile[0] = UNICODE_NULL;
1756
1757 /*
1758 * It is possible for a shell link to point to another shell link,
1759 * and in particular there is the possibility to point to itself.
1760 * Now, suppose we ask such a link to retrieve its associated icon.
1761 * This function would be called, and due to COM would be called again
1762 * recursively. To solve this issue, we forbid calling GetIconLocation()
1763 * with GIL_FORSHORTCUT set in uFlags, as done by Windows (shown by tests).
1764 */
1765 if (uFlags & GIL_FORSHORTCUT)
1766 return E_INVALIDARG;
1767
1768 /*
1769 * Now, we set GIL_FORSHORTCUT so that: i) we allow the icon extractor
1770 * of the target to give us a suited icon, and ii) we protect ourselves
1771 * against recursive call.
1772 */
1773 uFlags |= GIL_FORSHORTCUT;
1774
1775 if (uFlags & GIL_DEFAULTICON)
1776 return S_FALSE;
1777
1778 hr = GetIconLocation(pszIconFile, cchMax, piIndex);
1779 if (FAILED(hr) || pszIconFile[0] == UNICODE_NULL)
1780 {
1781 hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1782 }
1783 else
1784 {
1785 *pwFlags = GIL_NOTFILENAME | GIL_PERCLASS;
1786 }
1787
1788 return hr;
1789}
#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 1150 of file CShellLink.cpp.

1151{
1152 TRACE("(%p)->(ppidl=%p)\n", this, ppidl);
1153
1154 if (!m_pPidl)
1155 {
1156 *ppidl = NULL;
1157 return S_FALSE;
1158 }
1159
1160 *ppidl = ILClone(m_pPidl);
1161 return S_OK;
1162}
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 1101 of file CShellLink.cpp.

1102{
1103 HRESULT hr;
1104 LPWSTR pszFileW;
1105 WIN32_FIND_DATAW wfd;
1106
1107 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1108 this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1109
1110 /* Allocate a temporary UNICODE buffer */
1111 pszFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, max(cchMaxPath, MAX_PATH) * sizeof(WCHAR));
1112 if (!pszFileW)
1113 return E_OUTOFMEMORY;
1114
1115 /* Call the UNICODE function */
1116 hr = GetPath(pszFileW, cchMaxPath, &wfd, fFlags);
1117
1118 /* Convert the file path back to ANSI */
1119 WideCharToMultiByte(CP_ACP, 0, pszFileW, -1,
1120 pszFile, cchMaxPath, NULL, NULL);
1121
1122 /* Free the temporary buffer */
1123 HeapFree(GetProcessHeap(), 0, pszFileW);
1124
1125 if (pfd)
1126 {
1127 ZeroMemory(pfd, sizeof(*pfd));
1128
1129 /* Copy the file data if a file path was returned */
1130 if (*pszFile)
1131 {
1132 DWORD len;
1133
1134 /* Copy the fixed part */
1135 CopyMemory(pfd, &wfd, FIELD_OFFSET(WIN32_FIND_DATAA, cFileName));
1136
1137 /* Convert the file names to ANSI */
1138 len = lstrlenW(wfd.cFileName);
1139 WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, len + 1,
1140 pfd->cFileName, sizeof(pfd->cFileName), NULL, NULL);
1141 len = lstrlenW(wfd.cAlternateFileName);
1142 WideCharToMultiByte(CP_ACP, 0, wfd.cAlternateFileName, len + 1,
1143 pfd->cAlternateFileName, sizeof(pfd->cAlternateFileName), NULL, NULL);
1144 }
1145 }
1146
1147 return hr;
1148}
#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 1515 of file CShellLink.cpp.

1516{
1518
1519 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1520 this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1521
1522 if (cchMaxPath)
1523 *pszFile = 0;
1524 // FIXME: What if cchMaxPath == 0 , or pszFile == NULL ??
1525
1526 // FIXME: What about Darwin??
1527
1528 /*
1529 * Retrieve the path to the target from the PIDL (if we have one).
1530 * NOTE: Do NOT use the cached path (m_sPath from link info).
1531 */
1533 {
1534 if (fFlags & SLGP_SHORTPATH)
1536 // FIXME: Add support for SLGP_UNCPRIORITY
1537 }
1538 else
1539 {
1540 *buffer = 0;
1541 }
1542
1543 /* If we have a FindData structure, initialize it */
1544 if (pfd)
1545 {
1546 ZeroMemory(pfd, sizeof(*pfd));
1547
1548 /* Copy the file data if the target is a file path */
1549 if (*buffer)
1550 {
1551 pfd->dwFileAttributes = m_Header.dwFileAttributes;
1552 pfd->ftCreationTime = m_Header.ftCreationTime;
1553 pfd->ftLastAccessTime = m_Header.ftLastAccessTime;
1554 pfd->ftLastWriteTime = m_Header.ftLastWriteTime;
1555 pfd->nFileSizeHigh = 0;
1556 pfd->nFileSizeLow = m_Header.nFileSizeLow;
1557
1558 /*
1559 * Build temporarily a short path in pfd->cFileName (of size MAX_PATH),
1560 * then extract and store the short file name in pfd->cAlternateFileName.
1561 */
1562 GetShortPathNameW(buffer, pfd->cFileName, _countof(pfd->cFileName));
1563 lstrcpynW(pfd->cAlternateFileName,
1564 PathFindFileNameW(pfd->cFileName),
1565 _countof(pfd->cAlternateFileName));
1566
1567 /* Now extract and store the long file name in pfd->cFileName */
1568 lstrcpynW(pfd->cFileName,
1570 _countof(pfd->cFileName));
1571 }
1572 }
1573
1574 /* Finally check if we have a raw path the user actually wants to retrieve */
1575 if ((fFlags & SLGP_RAWPATH) && (m_Header.dwFlags & SLDF_HAS_EXP_SZ))
1576 {
1577 /* Search for a target environment block */
1578 LPEXP_SZ_LINK pInfo;
1580 if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1581 lstrcpynW(buffer, pInfo->szwTarget, cchMaxPath);
1582 }
1583
1584 /* For diagnostics purposes only... */
1585 // NOTE: SLGP_UNCPRIORITY is unsupported
1586 fFlags &= ~(SLGP_RAWPATH | SLGP_SHORTPATH);
1587 if (fFlags) FIXME("(%p): Unsupported flags %lu\n", this, fFlags);
1588
1589 /* Copy the data back to the user */
1590 if (*buffer)
1591 lstrcpynW(pszFile, buffer, cchMaxPath);
1592
1593 return (*buffer ? S_OK : S_FALSE);
1594}
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:1348
#define EXP_SZ_LINK_SIG
Definition: shlobj.h:2051

◆ GetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::GetShowCmd ( INT piShowCmd)
override

Definition at line 1283 of file CShellLink.cpp.

1284{
1285 TRACE("(%p)->(%p) %d\n", this, piShowCmd, m_Header.nShowCommand);
1286 *piShowCmd = m_Header.nShowCommand;
1287 return S_OK;
1288}

◆ GetSite()

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

Definition at line 3126 of file CShellLink.cpp.

3127{
3128 TRACE("%p %s %p\n", this, debugstr_guid(&iid), ppvSite);
3129
3130 if (m_site == NULL)
3131 return E_FAIL;
3132
3133 return m_site->QueryInterface(iid, ppvSite);
3134}
#define debugstr_guid
Definition: kernel32.h:35

◆ GetSizeMax()

HRESULT STDMETHODCALLTYPE CShellLink::GetSizeMax ( ULARGE_INTEGER pcbSize)
override

Implements IPersistStream.

Definition at line 1033 of file CShellLink.cpp.

1034{
1035 TRACE("(%p)\n", this);
1036 return E_NOTIMPL;
1037}

◆ GetWorkingDirectory() [1/2]

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

Definition at line 1202 of file CShellLink.cpp.

1203{
1204 TRACE("(%p)->(%p len=%u)\n", this, pszDir, cchMaxPath);
1205
1206 if (cchMaxPath)
1207 *pszDir = 0;
1208
1209 if (m_sWorkDir)
1211 pszDir, cchMaxPath, NULL, NULL);
1212
1213 return S_OK;
1214}
_In_ LPCSTR pszDir
Definition: shellapi.h:584

◆ GetWorkingDirectory() [2/2]

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

Definition at line 1625 of file CShellLink.cpp.

1626{
1627 TRACE("(%p)->(%p len %u)\n", this, pszDir, cchMaxPath);
1628
1629 if (cchMaxPath)
1630 *pszDir = 0;
1631
1632 if (m_sWorkDir)
1633 lstrcpynW(pszDir, m_sWorkDir, cchMaxPath);
1634
1635 return S_OK;
1636}

◆ Initialize()

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

Implements IShellExtInit.

Definition at line 2497 of file CShellLink.cpp.

2498{
2499 TRACE("%p %p %p %p\n", this, pidlFolder, pdtobj, hkeyProgID);
2500
2501 if (!pdtobj)
2502 return E_FAIL;
2503
2504 FORMATETC format;
2505 format.cfFormat = CF_HDROP;
2506 format.ptd = NULL;
2507 format.dwAspect = DVASPECT_CONTENT;
2508 format.lindex = -1;
2509 format.tymed = TYMED_HGLOBAL;
2510
2511 STGMEDIUM stgm;
2512 HRESULT hr = pdtobj->GetData(&format, &stgm);
2513 if (FAILED(hr))
2514 return hr;
2515
2516 UINT count = DragQueryFileW((HDROP)stgm.hGlobal, -1, NULL, 0);
2517 if (count == 1)
2518 {
2519 count = DragQueryFileW((HDROP)stgm.hGlobal, 0, NULL, 0);
2520 count++;
2521 LPWSTR path = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
2522 if (path)
2523 {
2524 count = DragQueryFileW((HDROP)stgm.hGlobal, 0, path, count);
2525 hr = Load(path, 0);
2527 }
2528 }
2529 ReleaseStgMedium(&stgm);
2530
2531 return S_OK;
2532}
#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 2592 of file CShellLink.cpp.

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

◆ IsDirty()

HRESULT STDMETHODCALLTYPE CShellLink::IsDirty ( void  )
override

Implements IPersistStream.

Definition at line 318 of file CShellLink.cpp.

319{
320 TRACE("(%p)\n", this);
321 return (m_bDirty ? S_OK : S_FALSE);
322}

◆ Load() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::Load ( IStream stm)
override

Implements IPersistStream.

Definition at line 631 of file CShellLink.cpp.

632{
633 TRACE("%p %p\n", this, stm);
634
635 if (!stm)
637
638 /* Free all the old stuff */
639 Reset();
640
641 ULONG dwBytesRead = 0;
642 HRESULT hr = stm->Read(&m_Header, sizeof(m_Header), &dwBytesRead);
643 if (FAILED(hr))
644 return hr;
645
646 if (dwBytesRead != sizeof(m_Header))
647 return E_FAIL;
648 if (m_Header.dwSize != sizeof(m_Header))
649 return E_FAIL;
650 if (!IsEqualIID(m_Header.clsid, CLSID_ShellLink))
651 return E_FAIL;
652
653 /* Load the new data in order */
654
655 if (TRACE_ON(shell))
656 {
657 SYSTEMTIME stCreationTime;
658 SYSTEMTIME stLastAccessTime;
659 SYSTEMTIME stLastWriteTime;
660 WCHAR sTemp[MAX_PATH];
661
665
667 NULL, sTemp, _countof(sTemp));
668 TRACE("-- stCreationTime: %s\n", debugstr_w(sTemp));
670 NULL, sTemp, _countof(sTemp));
671 TRACE("-- stLastAccessTime: %s\n", debugstr_w(sTemp));
673 NULL, sTemp, _countof(sTemp));
674 TRACE("-- stLastWriteTime: %s\n", debugstr_w(sTemp));
675 }
676
677 /* load all the new stuff */
679 {
680 hr = ILLoadFromStream(stm, &m_pPidl);
681 if (FAILED(hr))
682 return hr;
683 }
684 pdump(m_pPidl);
685
686 /* Load the location information... */
688 {
690 if (FAILED(hr))
691 return hr;
692 }
693 /* ... but if it is required not to use it, clear it */
695 {
697 m_sPath = NULL;
698 ZeroMemory(&volume, sizeof(volume));
699 }
700
701 BOOL unicode = !!(m_Header.dwFlags & SLDF_UNICODE);
702
704 {
705 hr = Stream_LoadString(stm, unicode, &m_sDescription);
706 if (FAILED(hr))
707 return hr;
708 TRACE("Description -> %s\n", debugstr_w(m_sDescription));
709 }
710
712 {
713 hr = Stream_LoadString(stm, unicode, &m_sPathRel);
714 if (FAILED(hr))
715 return hr;
716 TRACE("Relative Path-> %s\n", debugstr_w(m_sPathRel));
717 }
718
720 {
721 hr = Stream_LoadString(stm, unicode, &m_sWorkDir);
722 if (FAILED(hr))
723 return hr;
725 TRACE("Working Dir -> %s\n", debugstr_w(m_sWorkDir));
726 }
727
729 {
730 hr = Stream_LoadString(stm, unicode, &m_sArgs);
731 if (FAILED(hr))
732 return hr;
733 TRACE("Arguments -> %s\n", debugstr_w(m_sArgs));
734 }
735
737 {
738 hr = Stream_LoadString(stm, unicode, &m_sIcoPath);
739 if (FAILED(hr))
740 return hr;
741 TRACE("Icon file -> %s\n", debugstr_w(m_sIcoPath));
742 }
743
744 /* Now load the optional data block list */
746 if (FAILED(hr)) // FIXME: Should we fail?
747 return hr;
748
750 if (pSpecial && pSpecial->cbSize == sizeof(*pSpecial) && ILGetSize(m_pPidl) > pSpecial->cbOffset)
751 {
753 {
754 LPITEMIDLIST pidl = ILCombine(folder, (LPITEMIDLIST)((char*)m_pPidl + pSpecial->cbOffset));
755 if (pidl)
756 {
758 m_pPidl = pidl;
759 TRACE("Replaced pidl base with CSIDL %u up to %ub.\n", pSpecial->idSpecialFolder, pSpecial->cbOffset);
760 }
761 ILFree(folder);
762 }
763 }
764
765 if (TRACE_ON(shell))
766 {
767#if (NTDDI_VERSION < NTDDI_LONGHORN)
769 {
770 hr = GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
771 if (SUCCEEDED(hr))
772 TRACE("Product -> %s\n", debugstr_w(sProduct));
773 }
774#endif
776 {
778 if (SUCCEEDED(hr))
779 TRACE("Component -> %s\n", debugstr_w(sComponent));
780 }
781 }
782
784 m_bRunAs = TRUE;
785 else
786 m_bRunAs = FALSE;
787
788 TRACE("OK\n");
789
790 pdump(m_pPidl);
791
792 return S_OK;
793}
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:311
#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:443
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:718
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 324 of file CShellLink.cpp.

325{
326 TRACE("(%p, %s, %x)\n", this, debugstr_w(pszFileName), dwMode);
327
328 if (dwMode == 0)
330
333 if (SUCCEEDED(hr))
334 {
337 hr = Load(stm);
339 m_bDirty = FALSE;
340 }
341 TRACE("-- returning hr %08x\n", hr);
342 return hr;
343}
HRESULT 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 2917 of file CShellLink.cpp.

2918{
2919 switch (id)
2920 {
2921 case IDC_SHORTCUT_FIND:
2923 return;
2924
2926 {
2927 WCHAR wszPath[MAX_PATH] = L"";
2928
2929 if (m_sIcoPath)
2930 wcscpy(wszPath, m_sIcoPath);
2931 else
2932 FindExecutableW(m_sPath, NULL, wszPath);
2933
2935 if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
2936 {
2937 SetIconLocation(wszPath, IconIndex);
2938 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2939
2940 HICON hIconLarge = CreateShortcutIcon(wszPath, IconIndex);
2941 if (hIconLarge)
2942 {
2943 if (m_hIcon)
2945 m_hIcon = hIconLarge;
2947 }
2948 }
2949 return;
2950 }
2951
2953 {
2955 if (result == 1 || result == 0)
2956 {
2957 if (m_bRunAs != result)
2958 {
2959 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2960 }
2961
2962 m_bRunAs = result;
2963 }
2964 return;
2965 }
2966 }
2967 if (codeNotify == EN_CHANGE || codeNotify == CBN_SELCHANGE)
2968 {
2969 if (!m_bInInit)
2970 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2971 }
2972}
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:1273
EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD dwFlags)
Definition: shlfolder.cpp:437
#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 3042 of file CShellLink.cpp.

3043{
3044 if (m_hIcon)
3045 {
3047 m_hIcon = NULL;
3048 }
3049}

◆ OnInitDialog()

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

Definition at line 2760 of file CShellLink.cpp.

2761{
2762 TRACE("CShellLink::OnInitDialog(hwnd %p hwndFocus %p lParam %p)\n", hwndDlg, hwndFocus, lParam);
2763
2765
2766 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,
2768
2769 m_bInInit = TRUE;
2771
2772 /* Get file information */
2773 // FIXME! FIXME! Shouldn't we use m_sIcoPath, m_Header.nIconIndex instead???
2774 SHFILEINFOW fi;
2775 if (!SHGetFileInfoW(m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_ICON))
2776 {
2777 ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_sLinkPath, GetLastError());
2778 fi.szTypeName[0] = L'\0';
2779 fi.hIcon = NULL;
2780 }
2781
2782 if (fi.hIcon)
2783 {
2784 if (m_hIcon)
2786 m_hIcon = fi.hIcon;
2788 }
2789 else
2790 ERR("ExtractIconW failed %ls %u\n", m_sIcoPath, m_Header.nIconIndex);
2791
2792 if (!SHGetFileInfoW(m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME))
2795
2796 /* Target type */
2797 if (m_sPath)
2798 {
2802 }
2803
2804 /* Target location */
2805 if (m_sPath)
2806 {
2811 }
2812
2813 /* Target path */
2814 if (m_sPath)
2815 {
2816 WCHAR newpath[MAX_PATH * 2];
2817 newpath[0] = UNICODE_NULL;
2818 if (wcschr(m_sPath, ' '))
2819 StringCchPrintfExW(newpath, _countof(newpath), NULL, NULL, 0, L"\"%ls\"", m_sPath);
2820 else
2821 StringCchCopyExW(newpath, _countof(newpath), m_sPath, NULL, NULL, 0);
2822
2823 if (m_sArgs && m_sArgs[0])
2824 {
2825 StringCchCatW(newpath, _countof(newpath), L" ");
2826 StringCchCatW(newpath, _countof(newpath), m_sArgs);
2827 }
2828 SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, newpath);
2829 }
2830
2831 /* Working dir */
2832 if (m_sWorkDir)
2834
2835 /* Description */
2836 if (m_sDescription)
2838
2839 /* Hot key */
2841
2842 /* Run */
2844 const DWORD runshowcmd[] = { SW_SHOWNORMAL, SW_SHOWMINNOACTIVE, SW_SHOWMAXIMIZED };
2845 HWND hRunCombo = GetDlgItem(hwndDlg, IDC_SHORTCUT_RUN_COMBO);
2846 for (UINT i = 0; i < _countof(runstrings); ++i)
2847 {
2849 if (!LoadStringW(shell32_hInstance, runstrings[i], buf, _countof(buf)))
2850 break;
2851
2852 int index = SendMessageW(hRunCombo, CB_ADDSTRING, 0, (LPARAM)buf);
2853 if (index < 0)
2854 continue;
2855 SendMessageW(hRunCombo, CB_SETITEMDATA, index, runshowcmd[i]);
2856 if (!i || m_Header.nShowCommand == runshowcmd[i])
2857 SendMessageW(hRunCombo, CB_SETCURSEL, index, 0);
2858 }
2859
2860 BOOL disablecontrols = FALSE;
2861 if (darwin)
2862 {
2863 disablecontrols = TRUE;
2866 }
2867 else
2868 {
2869 WCHAR path[MAX_PATH * 2];
2870 path[0] = UNICODE_NULL;
2872 if (FAILED(hr))
2873 hr = GetPath(path, _countof(path), NULL, 0);
2874#if DBG
2875 if (GetKeyState(VK_CONTROL) < 0) // Allow inspection of PIDL parsing path
2876 {
2877 hr = S_OK;
2878 path[0] = UNICODE_NULL;
2879 }
2880#endif
2881 if (hr != S_OK)
2882 {
2883 disablecontrols = TRUE;
2884 LPITEMIDLIST pidl;
2885 if (GetIDList(&pidl) == S_OK)
2886 {
2887 path[0] = UNICODE_NULL;
2888 SHGetNameAndFlagsW(pidl, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING, path, _countof(path), NULL);
2891 ILRemoveLastID(pidl);
2892 path[0] = UNICODE_NULL;
2894 SHGetNameAndFlagsW(pidl, SHGDN_NORMAL, path, _countof(path), NULL);
2896 ILFree(pidl);
2897 }
2900 }
2901 else
2902 {
2903 ASSERT(FAILED(hr) || !(path[0] == ':' && path[1] == ':' && path[2] == '{'));
2904 }
2905 }
2906 EnableWindow(GetDlgItem(hwndDlg, IDC_SHORTCUT_TARGET_TEXT), !disablecontrols);
2907
2908 /* auto-completion */
2911
2912 m_bInInit = FALSE;
2913
2914 return TRUE;
2915}
#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:289
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:414
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:166
#define SHGFI_ICON
Definition: shellapi.h:164
#define SHGFI_TYPENAME
Definition: shellapi.h:167
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:376
WCHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:375
HICON hIcon
Definition: shellapi.h:372
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 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 2974 of file CShellLink.cpp.

2975{
2976 WCHAR wszBuf[MAX_PATH];
2977 LPPSHNOTIFY lppsn = (LPPSHNOTIFY)pnmhdr;
2978
2979 if (lppsn->hdr.code == PSN_APPLY)
2980 {
2981 /* set working directory */
2982 GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, wszBuf, _countof(wszBuf));
2983 SetWorkingDirectory(wszBuf);
2984
2985 /* set link destination */
2986 GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf));
2987 LPWSTR lpszArgs = NULL;
2988 LPWSTR unquoted = strdupW(wszBuf);
2989 StrTrimW(unquoted, L" ");
2990
2991 if (!PathFileExistsW(unquoted))
2992 {
2993 lpszArgs = PathGetArgsW(unquoted);
2994 PathRemoveArgsW(unquoted);
2995 StrTrimW(lpszArgs, L" ");
2996 }
2997 if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
2998 PathUnquoteSpacesW(unquoted);
2999
3000 WCHAR *pwszExt = PathFindExtensionW(unquoted);
3001 if (!_wcsicmp(pwszExt, L".lnk"))
3002 {
3003 // FIXME load localized error msg
3004 MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR);
3006 return TRUE;
3007 }
3008
3009 if (!PathFileExistsW(unquoted))
3010 {
3011 // FIXME load localized error msg
3012 MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", L"Error", MB_ICONERROR);
3014 return TRUE;
3015 }
3016
3017 SetPath(unquoted);
3018 if (lpszArgs)
3019 SetArguments(lpszArgs);
3020 else
3021 SetArguments(L"\0");
3022
3023 HeapFree(GetProcessHeap(), 0, unquoted);
3024
3026
3028 if (index != CB_ERR)
3029 {
3031 }
3032
3033 TRACE("This %p m_sLinkPath %S\n", this, m_sLinkPath);
3037 return TRUE;
3038 }
3039 return FALSE;
3040}
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:1777
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
LPWSTR WINAPI PathGetArgsW(LPCWSTR lpszPath)
Definition: path.c:506
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1877
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 2534 of file CShellLink.cpp.

2535{
2536 INT id = 0;
2537
2538 m_idCmdFirst = idCmdFirst;
2539
2540 TRACE("%p %p %u %u %u %u\n", this,
2541 hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
2542
2543 if (!hMenu)
2544 return E_INVALIDARG;
2545
2548
2549 MENUITEMINFOW mii;
2550 ZeroMemory(&mii, sizeof(mii));
2551 mii.cbSize = sizeof(mii);
2553 mii.dwTypeData = strOpen.GetBuffer();
2554 mii.cch = wcslen(mii.dwTypeData);
2555 mii.wID = idCmdFirst + id++;
2557 mii.fType = MFT_STRING;
2558 if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2559 return E_FAIL;
2560
2562 mii.dwTypeData = strOpenFileLoc.GetBuffer();
2563 mii.cch = wcslen(mii.dwTypeData);
2564 mii.wID = idCmdFirst + id++;
2565 mii.fState = MFS_ENABLED;
2566 mii.fType = MFT_STRING;
2567 if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2568 return E_FAIL;
2569
2570 UNREFERENCED_PARAMETER(indexMenu);
2571
2572 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, id);
2573}
#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 2463 of file CShellLink.cpp.

2464{
2465 if (SHRemoveDataBlock(&m_pDBList, dwSig))
2466 {
2467 m_bDirty = TRUE;
2468 return S_OK;
2469 }
2470 return S_FALSE;
2471}
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 3111 of file CShellLink.cpp.

3112{
3113 TRACE("(%p) (uPageID %u, pfnReplacePage %p lParam %p\n", this, uPageID, pfnReplacePage, lParam);
3114 return E_NOTIMPL;
3115}

◆ Reset()

VOID CShellLink::Reset ( )
private

Definition at line 220 of file CShellLink.cpp.

Referenced by Load().

◆ Resolve()

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

Implements IShellLinkA.

Definition at line 1429 of file CShellLink.cpp.

1430{
1431 HRESULT hr = S_OK;
1432 BOOL bSuccess;
1433
1434 TRACE("(%p)->(hwnd=%p flags=%x)\n", this, hwnd, fFlags);
1435
1436 /* FIXME: use IResolveShellLink interface? */
1437
1438 // FIXME: See InvokeCommand().
1439
1440#if (NTDDI_VERSION < NTDDI_LONGHORN)
1441 // NOTE: For Logo3 (EXP_LOGO3_ID_SIG), check also for SHRestricted(REST_NOLOGO3CHANNELNOTIFY)
1443 {
1444 FIXME("Logo3 links are not supported yet!\n");
1445 return E_FAIL;
1446 }
1447#endif
1448
1449 /* Resolve Darwin (MSI) target */
1451 {
1452 LPWSTR component = NULL;
1453 hr = GetAdvertiseInfo(&component, EXP_DARWIN_ID_SIG);
1454 if (FAILED(hr))
1455 return E_FAIL;
1456
1457 /* Clear the cached path */
1460 if (!m_sPath)
1461 return E_FAIL;
1462 }
1463
1464 if (!m_sPath && m_pPidl)
1465 {
1467
1469 if (bSuccess && *buffer)
1470 {
1472 if (!m_sPath)
1473 return E_OUTOFMEMORY;
1474
1475 m_bDirty = TRUE;
1476 }
1477 else
1478 {
1479 hr = S_OK; /* don't report an error occurred while just caching information */
1480 }
1481 }
1482
1483 // FIXME: Strange to do that here...
1484 if (!m_sIcoPath && m_sPath)
1485 {
1487 if (!m_sIcoPath)
1488 return E_OUTOFMEMORY;
1489
1490 m_Header.nIconIndex = 0;
1491
1492 m_bDirty = TRUE;
1493 }
1494
1495 return hr;
1496}
static BOOLEAN bSuccess
Definition: drive.cpp:477
_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 894 of file CShellLink.cpp.

895{
896 TRACE("%p %p %x\n", this, stm, fClearDirty);
897
898 m_Header.dwSize = sizeof(m_Header);
899 m_Header.clsid = CLSID_ShellLink;
900
901 /* Store target attributes */
902 WIN32_FIND_DATAW wfd = {};
903 WCHAR FsTarget[MAX_PATH];
904 if (GetPath(FsTarget, _countof(FsTarget), NULL, 0) == S_OK && PathFileExistsW(FsTarget))
905 {
906 HANDLE hFind = FindFirstFileW(FsTarget, &wfd);
907 if (hFind != INVALID_HANDLE_VALUE)
908 FindClose(hFind);
909 }
910 m_Header.dwFileAttributes = wfd.dwFileAttributes;
911 m_Header.ftCreationTime = wfd.ftCreationTime;
912 m_Header.ftLastAccessTime = wfd.ftLastAccessTime;
913 m_Header.ftLastWriteTime = wfd.ftLastWriteTime;
914 m_Header.nFileSizeLow = wfd.nFileSizeLow;
915
916 /*
917 * Reset the flags: keep only the flags related to data blocks as they were
918 * already set in accordance by the different mutator member functions.
919 * The other flags will be determined now by the presence or absence of data.
920 */
923#if (NTDDI_VERSION < NTDDI_LONGHORN)
925#endif
927 // TODO: When we will support Vista+ functionality, add other flags to this list.
928
929 /* The stored strings are in UNICODE */
931
932 if (m_pPidl)
938 if (m_sPathRel && *m_sPathRel)
940 if (m_sWorkDir && *m_sWorkDir)
942 if (m_sArgs && *m_sArgs)
944 if (m_sIcoPath && *m_sIcoPath)
946 if (m_bRunAs)
948
949 /* Write the shortcut header */
950 ULONG count;
951 HRESULT hr = stm->Write(&m_Header, sizeof(m_Header), &count);
952 if (FAILED(hr))
953 {
954 ERR("Write failed\n");
955 return hr;
956 }
957
958 /* Save the data in order */
959
960 if (m_pPidl)
961 {
962 hr = ILSaveToStream(stm, m_pPidl);
963 if (FAILED(hr))
964 {
965 ERR("Failed to write PIDL\n");
966 return hr;
967 }
968 }
969
971 {
973 if (FAILED(hr))
974 return hr;
975 }
976
978 {
980 if (FAILED(hr))
981 return hr;
982 }
983
985 {
987 if (FAILED(hr))
988 return hr;
989 }
990
992 {
994 if (FAILED(hr))
995 return hr;
996 }
997
999 {
1001 if (FAILED(hr))
1002 return hr;
1003 }
1004
1006 {
1008 if (FAILED(hr))
1009 return hr;
1010 }
1011
1012 /*
1013 * Now save the data block list.
1014 *
1015 * NOTE that both advertised Product and Component are already saved
1016 * inside Logo3 and Darwin data blocks in the m_pDBList list, and the
1017 * m_Header.dwFlags is suitably initialized.
1018 */
1020 if (FAILED(hr))
1021 return hr;
1022
1023 /* Clear the dirty bit if requested */
1024 if (fClearDirty)
1025 m_bDirty = FALSE;
1026
1027 return hr;
1028}
#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:351
@ 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 345 of file CShellLink.cpp.

346{
347 BOOL bAlreadyExists;
348 WCHAR szFullPath[MAX_PATH];
349
350 TRACE("(%p)->(%s)\n", this, debugstr_w(pszFileName));
351
352 if (!pszFileName)
353 return E_FAIL;
354
355 bAlreadyExists = PathFileExistsW(pszFileName);
356
359 if (SUCCEEDED(hr))
360 {
361 hr = Save(stm, FALSE);
362
363 if (SUCCEEDED(hr))
364 {
365 GetFullPathNameW(pszFileName, _countof(szFullPath), szFullPath, NULL);
366 if (bAlreadyExists)
368 else
370
371 if (m_sLinkPath)
373
375 m_bDirty = FALSE;
376 }
377 else
378 {
380 WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName));
381 }
382 }
383
384 return hr;
385}
#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 387 of file CShellLink.cpp.

388{
389 FIXME("(%p)->(%s)\n", this, debugstr_w(pszFileName));
390 return S_OK;
391}

◆ SetAdvertiseInfo()

HRESULT CShellLink::SetAdvertiseInfo ( LPCWSTR  str)
private

Definition at line 2136 of file CShellLink.cpp.

2137{
2138 HRESULT hr;
2139 LPCWSTR szComponent = NULL, szProduct = NULL, p;
2140 INT len;
2141 GUID guid;
2142 WCHAR szGuid[38+1];
2143
2145
2146 while (str[0])
2147 {
2148 /* each segment must start with two colons */
2149 if (str[0] != ':' || str[1] != ':')
2150 return E_FAIL;
2151
2152 /* the last segment is just two colons */
2153 if (!str[2])
2154 break;
2155 str += 2;
2156
2157 /* there must be a colon straight after a guid */
2158 p = wcschr(str, L':');
2159 if (!p)
2160 return E_FAIL;
2161 len = p - str;
2162 if (len != 38)
2163 return E_FAIL;
2164
2165 /* get the guid, and check if it's validly formatted */
2166 memcpy(szGuid, str, sizeof(WCHAR)*len);
2167 szGuid[len] = 0;
2168
2170 if (hr != S_OK)
2171 return hr;
2172 str = p + 1;
2173
2174 /* match it up to a guid that we care about */
2175 if (IsEqualGUID(guid, SHELL32_AdvtShortcutComponent) && !szComponent)
2176 szComponent = str; /* Darwin */
2177 else if (IsEqualGUID(guid, SHELL32_AdvtShortcutProduct) && !szProduct)
2178 szProduct = str; /* Logo3 */
2179 else
2180 return E_FAIL;
2181
2182 /* skip to the next field */
2183 str = wcschr(str, L':');
2184 if (!str)
2185 return E_FAIL;
2186 }
2187
2188 /* we have to have a component for an advertised shortcut */
2189 if (!szComponent)
2190 return E_FAIL;
2191
2192 szComponent = GetAdvertisedArg(szComponent);
2193 szProduct = GetAdvertisedArg(szProduct);
2194
2195 hr = WriteAdvertiseInfo(szComponent, EXP_DARWIN_ID_SIG);
2196 // if (FAILED(hr))
2197 // return hr;
2198#if (NTDDI_VERSION < NTDDI_LONGHORN)
2199 hr = WriteAdvertiseInfo(szProduct, EXP_LOGO3_ID_SIG);
2200 // if (FAILED(hr))
2201 // return hr;
2202#endif
2203
2204 HeapFree(GetProcessHeap(), 0, (PVOID)szComponent);
2205 HeapFree(GetProcessHeap(), 0, (PVOID)szProduct);
2206
2207 if (TRACE_ON(shell))
2208 {
2210 TRACE("Component = %s\n", debugstr_w(sComponent));
2211#if (NTDDI_VERSION < NTDDI_LONGHORN)
2212 GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
2213 TRACE("Product = %s\n", debugstr_w(sProduct));
2214#endif
2215 }
2216
2217 return S_OK;
2218}
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 1248 of file CShellLink.cpp.

1249{
1250 TRACE("(%p)->(args=%s)\n", this, pszArgs);
1251
1253 m_sArgs = NULL;
1254
1255 if (pszArgs)
1256 {
1257 m_sArgs = HEAP_strdupAtoW(GetProcessHeap(), 0, pszArgs);
1258 if (!m_sArgs)
1259 return E_OUTOFMEMORY;
1260 }
1261 m_bDirty = TRUE;
1262
1263 return S_OK;
1264}

Referenced by OnNotify().

◆ SetArguments() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCWSTR  pszArgs)
override

Implements IShellLinkW.

Definition at line 1669 of file CShellLink.cpp.

1670{
1671 TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs));
1672
1674 m_sArgs = NULL;
1675
1676 if (pszArgs)
1677 {
1678 m_sArgs = strdupW(pszArgs);
1679 if (!m_sArgs)
1680 return E_OUTOFMEMORY;
1681 }
1682 m_bDirty = TRUE;
1683
1684 return S_OK;
1685}

◆ SetDescription() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCSTR  pszName)
override

Implements IShellLinkA.

Definition at line 1184 of file CShellLink.cpp.

1185{
1186 TRACE("(%p)->(pName=%s)\n", this, pszName);
1187
1190
1191 if (pszName)
1192 {
1194 if (!m_sDescription)
1195 return E_OUTOFMEMORY;
1196 }
1197 m_bDirty = TRUE;
1198
1199 return S_OK;
1200}

◆ SetDescription() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCWSTR  pszName)
override

Implements IShellLinkW.

Definition at line 1607 of file CShellLink.cpp.

1608{
1609 TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
1610
1613
1614 if (pszName)
1615 {
1616 m_sDescription = strdupW(pszName);
1617 if (!m_sDescription)
1618 return E_OUTOFMEMORY;
1619 }
1620 m_bDirty = TRUE;
1621
1622 return S_OK;
1623}

◆ SetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::SetFlags ( DWORD  dwFlags)
override

Implements IShellLinkDataList.

Definition at line 2480 of file CShellLink.cpp.

2481{
2482#if 0 // FIXME!
2484 m_bDirty = TRUE;
2485 return S_OK;
2486#else
2487 FIXME("\n");
2488 return E_NOTIMPL;
2489#endif
2490}
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ SetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::SetHotkey ( WORD  wHotkey)
override

Implements IShellLinkA.

Definition at line 1273 of file CShellLink.cpp.

1274{
1275 TRACE("(%p)->(hotkey=%x)\n", this, wHotkey);
1276
1277 m_Header.wHotKey = wHotkey;
1278 m_bDirty = TRUE;
1279
1280 return S_OK;
1281}

◆ SetIconLocation() [1/2]

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

Definition at line 1370 of file CShellLink.cpp.

1371{
1372 TRACE("(%p)->(path=%s iicon=%u)\n", this, pszIconPath, iIcon);
1373
1374 LPWSTR str = NULL;
1375 if (pszIconPath)
1376 {
1377 str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
1378 if (!str)
1379 return E_OUTOFMEMORY;
1380 }
1381
1382 HRESULT hr = SetIconLocation(str, iIcon);
1383
1384 if (str)
1386
1387 return hr;
1388}

Referenced by OnCommand(), and SetIconLocation().

◆ SetIconLocation() [2/2]

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

Definition at line 1907 of file CShellLink.cpp.

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

1165{
1166 TRACE("(%p)->(pidl=%p)\n", this, pidl);
1167 return SetTargetFromPIDLOrPath(pidl, NULL);
1168}

◆ SetPath() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetPath ( LPCSTR  pszFile)
override

Implements IShellLinkA.

Definition at line 1498 of file CShellLink.cpp.

1499{
1500 TRACE("(%p)->(path=%s)\n", this, pszFile);
1501
1502 if (!pszFile)
1503 return E_INVALIDARG;
1504
1505 LPWSTR str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1506 if (!str)
1507 return E_OUTOFMEMORY;
1508
1509 HRESULT hr = SetPath(str);
1511
1512 return hr;
1513}

Referenced by OnNotify(), and SetPath().

◆ SetPath() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetPath ( LPCWSTR  pszFile)
override

Implements IShellLinkW.

Definition at line 2300 of file CShellLink.cpp.

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

1391{
1392 TRACE("(%p)->(path=%s %x)\n", this, pszPathRel, dwReserved);
1393
1395 m_sPathRel = NULL;
1396
1397 if (pszPathRel)
1398 {
1399 m_sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
1400 m_bDirty = TRUE;
1401 }
1402
1404}
_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 2033 of file CShellLink.cpp.

2034{
2035 TRACE("(%p)->(path=%s %x)\n", this, debugstr_w(pszPathRel), dwReserved);
2036
2038 m_sPathRel = NULL;
2039
2040 if (pszPathRel)
2041 {
2042 m_sPathRel = strdupW(pszPathRel);
2043 if (!m_sPathRel)
2044 return E_OUTOFMEMORY;
2045 }
2046 m_bDirty = TRUE;
2047
2049}

◆ SetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::SetShowCmd ( INT  iShowCmd)
override

Definition at line 1290 of file CShellLink.cpp.

1291{
1292 TRACE("(%p) %d\n", this, iShowCmd);
1293
1294 m_Header.nShowCommand = iShowCmd;
1295 m_bDirty = TRUE;
1296
1297 return S_OK;
1298}

◆ SetSite()

HRESULT STDMETHODCALLTYPE CShellLink::SetSite ( IUnknown punk)
override

Implements IObjectWithSite.

Definition at line 3117 of file CShellLink.cpp.

3118{
3119 TRACE("%p %p\n", this, punk);
3120
3121 m_site = punk;
3122
3123 return S_OK;
3124}

◆ SetTargetFromPIDLOrPath()

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

Definition at line 2220 of file CShellLink.cpp.

2221{
2222 HRESULT hr = S_OK;
2223 LPITEMIDLIST pidlNew = NULL;
2225
2226 /*
2227 * Not both 'pidl' and 'pszFile' should be set.
2228 * But either one or both can be NULL.
2229 */
2230 if (pidl && pszFile)
2231 return E_FAIL;
2232
2233 if (pidl)
2234 {
2235 /* Clone the PIDL */
2236 pidlNew = ILClone(pidl);
2237 if (!pidlNew)
2238 return E_FAIL;
2239 }
2240 else if (pszFile)
2241 {
2242 /* Build a PIDL for this path target */
2243 hr = SHILCreateFromPathW(pszFile, &pidlNew, NULL);
2244 if (FAILED(hr))
2245 {
2246 /* This failed, try to resolve the path, then create a simple PIDL */
2247
2250
2252 {
2253 hr = E_INVALIDARG;
2254 szPath[0] = 0;
2255 }
2256 else
2257 {
2258 hr = S_OK;
2260 // NOTE: Don't make it failed here even if pidlNew was NULL.
2261 // We don't fail on purpose even if SHSimpleIDListFromPathW returns NULL.
2262 // This behaviour has been verified with tests.
2263 }
2264 }
2265 }
2266 // else if (!pidl && !pszFile) { pidlNew = NULL; hr = S_OK; }
2267
2268 ILFree(m_pPidl);
2269 m_pPidl = pidlNew;
2270
2271 if (!pszFile)
2272 {
2273 if (SHGetPathFromIDListW(pidlNew, szPath))
2274 pszFile = szPath;
2275 }
2276
2277 // TODO: Fully update link info, tracker, file attribs...
2278
2279 // if (pszFile)
2280 if (!pszFile)
2281 {
2282 *szPath = L'\0';
2283 pszFile = szPath;
2284 }
2285
2286 /* Update the cached path (for link info) */
2288
2289 if (m_sPath)
2291
2292 m_sPath = strdupW(pszFile);
2293 if (!m_sPath)
2294 return E_OUTOFMEMORY;
2295
2296 m_bDirty = TRUE;
2297 return hr;
2298}
#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:2133
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:401
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
Definition: pidl.c:1132

Referenced by SetIDList(), and SetPath().

◆ SetWorkingDirectory() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory ( LPCSTR  pszDir)
override

Implements IShellLinkA.

Definition at line 1216 of file CShellLink.cpp.

1217{
1218 TRACE("(%p)->(dir=%s)\n", this, pszDir);
1219
1221 m_sWorkDir = NULL;
1222
1223 if (pszDir)
1224 {
1226 if (!m_sWorkDir)
1227 return E_OUTOFMEMORY;
1228 }
1229 m_bDirty = TRUE;
1230
1231 return S_OK;
1232}

Referenced by OnNotify().

◆ SetWorkingDirectory() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory ( LPCWSTR  pszDir)
override

Implements IShellLinkW.

Definition at line 1638 of file CShellLink.cpp.

1639{
1640 TRACE("(%p)->(dir=%s)\n", this, debugstr_w(pszDir));
1641
1643 m_sWorkDir = NULL;
1644
1645 if (pszDir)
1646 {
1648 if (!m_sWorkDir)
1649 return E_OUTOFMEMORY;
1650 }
1651 m_bDirty = TRUE;
1652
1653 return S_OK;
1654}

◆ SH_ShellLinkDlgProc()

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

Definition at line 3058 of file CShellLink.cpp.

3059{
3060 LPPROPSHEETPAGEW ppsp;
3061 CShellLink *pThis = reinterpret_cast<CShellLink *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
3062
3063 switch (uMsg)
3064 {
3065 case WM_INITDIALOG:
3066 ppsp = (LPPROPSHEETPAGEW)lParam;
3067 if (ppsp == NULL)
3068 break;
3069
3070 pThis = reinterpret_cast<CShellLink *>(ppsp->lParam);
3071 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pThis);
3072 return pThis->OnInitDialog(hwndDlg, (HWND)(wParam), lParam);
3073
3074 case WM_NOTIFY:
3075 return pThis->OnNotify(hwndDlg, (int)wParam, (NMHDR *)lParam);
3076
3077 case WM_COMMAND:
3078 pThis->OnCommand(hwndDlg, LOWORD(wParam), (HWND)lParam, HIWORD(wParam));
3079 break;
3080
3081 case WM_DESTROY:
3082 pThis->OnDestroy(hwndDlg);
3083 break;
3084
3085 default:
3086 break;
3087 }
3088
3089 return FALSE;
3090}
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 2070 of file CShellLink.cpp.

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