ReactOS 0.4.15-dev-8348-gc1b9bb5
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:1712
#define SW_SHOWNORMAL
Definition: winuser.h:770

◆ ~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:940
#define TRACE(s)
Definition: solgame.cpp:4

Member Function Documentation

◆ AddDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::AddDataBlock ( void pDataBlock)
override

Implements IShellLinkDataList.

Definition at line 2396 of file CShellLink.cpp.

2397{
2398 if (SHAddDataBlock(&m_pDBList, (DATABLOCK_HEADER*)pDataBlock))
2399 {
2400 m_bDirty = TRUE;
2401 return S_OK;
2402 }
2403 return S_FALSE;
2404}
#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 3027 of file CShellLink.cpp.

3028{
3030 if (hPage == NULL)
3031 {
3032 ERR("failed to create property sheet page\n");
3033 return E_FAIL;
3034 }
3035
3036 if (!pfnAddPage(hPage, lParam))
3037 return E_FAIL;
3038
3039 return S_OK;
3040}
#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:404
LONG_PTR LPARAM
Definition: windef.h:208

◆ CopyDataBlock()

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

Implements IShellLinkDataList.

Definition at line 2406 of file CShellLink.cpp.

2407{
2408 DATABLOCK_HEADER* pBlock;
2409 PVOID pDataBlock;
2410
2411 TRACE("%p %08x %p\n", this, dwSig, ppDataBlock);
2412
2413 *ppDataBlock = NULL;
2414
2415 pBlock = SHFindDataBlock(m_pDBList, dwSig);
2416 if (!pBlock)
2417 {
2418 ERR("unknown datablock %08x (not found)\n", dwSig);
2419 return E_FAIL;
2420 }
2421
2422 pDataBlock = LocalAlloc(LMEM_ZEROINIT, pBlock->cbSize);
2423 if (!pDataBlock)
2424 return E_OUTOFMEMORY;
2425
2426 CopyMemory(pDataBlock, pBlock, pBlock->cbSize);
2427
2428 *ppDataBlock = pDataBlock;
2429 return S_OK;
2430}
#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:375
#define CopyMemory
Definition: winbase.h:1710

◆ CreateShortcutIcon()

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

Definition at line 3155 of file CShellLink.cpp.

3156{
3158 const COLORREF crMask = GetSysColor(COLOR_3DFACE);
3159 WCHAR wszLnkIcon[MAX_PATH];
3160 int lnk_idx;
3161 HDC hDC;
3163 HICON hIcon = NULL, hNewIcon = NULL, hShortcut;
3164
3165 if (HLM_GetIconW(IDI_SHELL_SHORTCUT - 1, wszLnkIcon, _countof(wszLnkIcon), &lnk_idx))
3166 {
3167 ::ExtractIconExW(wszLnkIcon, lnk_idx, &hShortcut, NULL, 1);
3168 }
3169 else
3170 {
3172 IMAGE_ICON, cx, cy, 0);
3173 }
3174
3175 ::ExtractIconExW(wszIconPath, IconIndex, &hIcon, NULL, 1);
3176 if (!hIcon || !hShortcut || !himl)
3177 goto cleanup;
3178
3180 if (hDC)
3181 {
3182 // create 32bpp bitmap
3183 BITMAPINFO bi;
3184 ZeroMemory(&bi, sizeof(bi));
3185 bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
3186 bi.bmiHeader.biWidth = cx;
3187 bi.bmiHeader.biHeight = cy;
3188 bi.bmiHeader.biPlanes = 1;
3189 bi.bmiHeader.biBitCount = 32;
3190 LPVOID pvBits;
3191 HBITMAP hbm = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
3192 if (hbm)
3193 {
3194 // draw the icon image
3195 HGDIOBJ hbmOld = SelectObject(hDC, hbm);
3196 {
3197 HBRUSH hbr = CreateSolidBrush(crMask);
3198 RECT rc = { 0, 0, cx, cy };
3199 FillRect(hDC, &rc, hbr);
3200 DeleteObject(hbr);
3201
3202 DrawIconEx(hDC, 0, 0, hIcon, cx, cy, 0, NULL, DI_NORMAL);
3203 DrawIconEx(hDC, 0, 0, hShortcut, cx, cy, 0, NULL, DI_NORMAL);
3204 }
3205 SelectObject(hDC, hbmOld);
3206
3207 INT iAdded = ImageList_AddMasked(himl, hbm, crMask);
3208 hNewIcon = ImageList_GetIcon(himl, iAdded, ILD_NORMAL | ILD_TRANSPARENT);
3209
3211 }
3212 DeleteDC(hDC);
3213 }
3214
3215cleanup:
3216 if (hIcon)
3218 if (hShortcut)
3219 DestroyIcon(hShortcut);
3220 if (himl)
3222
3223 return hNewIcon;
3224}
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:92
static HICON
Definition: imagelist.c:84
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:585
#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:2247
#define SM_CYICON
Definition: winuser.h:973
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:2072
#define SM_CXICON
Definition: winuser.h:972
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2097
#define COLOR_3DFACE
Definition: winuser.h:929
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnCommand().

◆ DoOpen()

HRESULT CShellLink::DoOpen ( LPCMINVOKECOMMANDINFO  lpici)
private

Definition at line 2593 of file CShellLink.cpp.

2594{
2595 HRESULT hr;
2596 LPWSTR args = NULL;
2598 BOOL unicode = lpici->cbSize >= FIELD_OFFSET(CMINVOKECOMMANDINFOEX, ptInvoke) &&
2599 (lpici->fMask & CMIC_MASK_UNICODE);
2600
2601 if (unicode)
2602 {
2604 SIZE_T len = 2;
2605
2606 if (m_sArgs)
2607 len += wcslen(m_sArgs);
2608 if (iciex->lpParametersW)
2609 len += wcslen(iciex->lpParametersW);
2610
2611 args = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2612 *args = 0;
2613 if (m_sArgs)
2615 if (iciex->lpParametersW)
2616 {
2617 wcscat(args, L" ");
2618 wcscat(args, iciex->lpParametersW);
2619 }
2620 }
2621 else if (m_sArgs != NULL)
2622 {
2623 args = strdupW(m_sArgs);
2624 }
2625
2627 ZeroMemory(&sei, sizeof(sei));
2628 sei.cbSize = sizeof(sei);
2631 if (m_pPidl)
2632 {
2633 sei.lpIDList = m_pPidl;
2634 sei.fMask |= SEE_MASK_IDLIST;
2635 }
2636 else
2637 {
2638 sei.lpFile = path;
2639 }
2640 sei.lpParameters = args;
2641 sei.lpClass = m_sLinkPath;
2643 sei.lpDirectory = m_sWorkDir;
2644 sei.lpVerb = L"open";
2645
2646 // HACK for ShellExecuteExW
2647 if (m_sPath && wcsstr(m_sPath, L".cpl"))
2648 sei.lpVerb = L"cplopen";
2649
2650 if (ShellExecuteExW(&sei))
2651 hr = S_OK;
2652 else
2653 hr = E_FAIL;
2654
2657
2658 return hr;
2659}
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
#define HeapAlloc
Definition: compat.h:733
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
struct IContextMenu::tagCMInvokeCommandInfoEx * LPCMINVOKECOMMANDINFOEX
struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
if(dx< 0)
Definition: linetemp.h:194
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SEE_MASK_UNICODE
Definition: shellapi.h:37
#define SEE_MASK_ASYNCOK
Definition: shellapi.h:54
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
#define SEE_MASK_NOASYNC
Definition: shellapi.h:33
#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:2362
HRESULT hr
Definition: shlfolder.c:183
LPCWSTR lpDirectory
Definition: shellapi.h:334
LPCWSTR lpParameters
Definition: shellapi.h:333
Definition: match.c:390
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ DoOpenFileLocation()

HRESULT CShellLink::DoOpenFileLocation ( )
private

Definition at line 2544 of file CShellLink.cpp.

2545{
2546 WCHAR szParams[MAX_PATH + 64];
2547 StringCbPrintfW(szParams, sizeof(szParams), L"/select,%s", m_sPath);
2548
2549 INT_PTR ret;
2550 ret = reinterpret_cast<INT_PTR>(ShellExecuteW(NULL, NULL, L"explorer.exe", szParams,
2552 if (ret <= 32)
2553 {
2554 ERR("ret: %08lX\n", ret);
2555 return E_FAIL;
2556 }
2557
2558 return S_OK;
2559}
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2420
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 3067 of file CShellLink.cpp.

3069{
3070 TRACE("(%p)->(DataObject=%p)\n", this, pDataObject);
3071
3072 if (*pdwEffect == DROPEFFECT_NONE)
3073 return S_OK;
3074
3075 LPCITEMIDLIST pidlLast;
3077
3079
3080 if (SUCCEEDED(hr))
3081 {
3082 hr = psf->GetUIObjectOf(0, 1, &pidlLast, IID_NULL_PPV_ARG(IDropTarget, &m_DropTarget));
3083
3084 if (SUCCEEDED(hr))
3085 hr = m_DropTarget->DragEnter(pDataObject, dwKeyState, pt, pdwEffect);
3086 else
3087 *pdwEffect = DROPEFFECT_NONE;
3088 }
3089 else
3090 *pdwEffect = DROPEFFECT_NONE;
3091
3092 return S_OK;
3093}
#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:1350
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 3105 of file CShellLink.cpp.

3106{
3107 TRACE("(%p)\n", this);
3108 HRESULT hr = S_OK;
3109 if (m_DropTarget)
3110 {
3111 hr = m_DropTarget->DragLeave();
3113 }
3114
3115 return hr;
3116}
void Release()
Definition: atlcomcli.h:170

◆ DragOver()

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

Implements IDropTarget.

Definition at line 3095 of file CShellLink.cpp.

3097{
3098 TRACE("(%p)\n", this);
3099 HRESULT hr = S_OK;
3100 if (m_DropTarget)
3101 hr = m_DropTarget->DragOver(dwKeyState, pt, pdwEffect);
3102 return hr;
3103}

◆ Drop()

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

Implements IDropTarget.

Definition at line 3118 of file CShellLink.cpp.

3120{
3121 TRACE("(%p)\n", this);
3122 HRESULT hr = S_OK;
3123 if (m_DropTarget)
3124 hr = m_DropTarget->Drop(pDataObject, dwKeyState, pt, pdwEffect);
3125
3126 return hr;
3127}

◆ Extract() [1/2]

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

Implements IExtractIconA.

Definition at line 1319 of file CShellLink.cpp.

1320{
1321 TRACE("(%p)->(path=%s iicon=%u)\n", this, pszFile, nIconIndex);
1322
1323 LPWSTR str = NULL;
1324 if (pszFile)
1325 {
1326 str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1327 if (!str)
1328 return E_OUTOFMEMORY;
1329 }
1330
1331 HRESULT hr = Extract(str, nIconIndex, phiconLarge, phiconSmall, nIconSize);
1332
1333 if (str)
1335
1336 return hr;
1337}
const WCHAR * str

Referenced by Extract().

◆ Extract() [2/2]

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

Definition at line 1761 of file CShellLink.cpp.

1762{
1763 HRESULT hr = NOERROR;
1764 UINT cxyLarge = LOWORD(nIconSize), cxySmall = HIWORD(nIconSize);
1765
1766 if (phiconLarge)
1767 {
1768 *phiconLarge = NULL;
1769 PrivateExtractIconsW(pszFile, nIconIndex, cxyLarge, cxyLarge, phiconLarge, NULL, 1, 0);
1770
1771 if (*phiconLarge == NULL)
1772 hr = S_FALSE;
1773 }
1774
1775 if (phiconSmall)
1776 {
1777 *phiconSmall = NULL;
1778 PrivateExtractIconsW(pszFile, nIconIndex, cxySmall, cxySmall, phiconSmall, NULL, 1, 0);
1779
1780 if (*phiconSmall == NULL)
1781 hr = S_FALSE;
1782 }
1783
1784 if (hr == S_FALSE)
1785 {
1786 if (phiconLarge && *phiconLarge)
1787 {
1788 DestroyIcon(*phiconLarge);
1789 *phiconLarge = NULL;
1790 }
1791 if (phiconSmall && *phiconSmall)
1792 {
1793 DestroyIcon(*phiconSmall);
1794 *phiconSmall = NULL;
1795 }
1796 }
1797
1798 return hr;
1799}
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 1203 of file CShellLink.cpp.

1204{
1205 TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1206
1207 if (cchMaxPath)
1208 *pszArgs = 0;
1209
1210 if (m_sArgs)
1212 pszArgs, cchMaxPath, NULL, NULL);
1213
1214 return S_OK;
1215}
#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 1625 of file CShellLink.cpp.

1626{
1627 TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1628
1629 if (cchMaxPath)
1630 *pszArgs = 0;
1631
1632 if (m_sArgs)
1633 lstrcpynW(pszArgs, m_sArgs, cchMaxPath);
1634
1635 return S_OK;
1636}
#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 2661 of file CShellLink.cpp.

2662{
2663 FIXME("%p %lu %u %p %p %u\n", this, idCmd, uType, pwReserved, pszName, cchMax);
2664 return E_NOTIMPL;
2665}
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
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 1139 of file CShellLink.cpp.

1140{
1141 TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1142
1143 if (cchMaxName)
1144 *pszName = 0;
1145
1146 if (m_sDescription)
1148 pszName, cchMaxName, NULL, NULL);
1149
1150 return S_OK;
1151}

◆ GetDescription() [2/2]

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

Definition at line 1565 of file CShellLink.cpp.

1566{
1567 TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1568
1569 *pszName = 0;
1570 if (m_sDescription)
1571 lstrcpynW(pszName, m_sDescription, cchMaxName);
1572
1573 return S_OK;
1574}

◆ GetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::GetFlags ( DWORD pdwFlags)
override

Implements IShellLinkDataList.

Definition at line 2442 of file CShellLink.cpp.

2443{
2444 TRACE("%p %p\n", this, pdwFlags);
2445 *pdwFlags = m_Header.dwFlags;
2446 return S_OK;
2447}

◆ GetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::GetHotkey ( WORD pwHotkey)
override

Implements IShellLinkA.

Definition at line 1235 of file CShellLink.cpp.

1236{
1237 TRACE("(%p)->(%p)(0x%08x)\n", this, pwHotkey, m_Header.wHotKey);
1238 *pwHotkey = m_Header.wHotKey;
1239 return S_OK;
1240}

◆ GetIconLocation() [1/4]

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

Definition at line 1269 of file CShellLink.cpp.

1270{
1271 HRESULT hr;
1272 LPWSTR pszIconPathW;
1273
1274 TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1275
1276 /* Allocate a temporary UNICODE buffer */
1277 pszIconPathW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchIconPath * sizeof(WCHAR));
1278 if (!pszIconPathW)
1279 return E_OUTOFMEMORY;
1280
1281 /* Call the UNICODE function */
1282 hr = GetIconLocation(pszIconPathW, cchIconPath, piIcon);
1283
1284 /* Convert the file path back to ANSI */
1285 WideCharToMultiByte(CP_ACP, 0, pszIconPathW, -1,
1286 pszIconPath, cchIconPath, NULL, NULL);
1287
1288 /* Free the temporary buffer */
1289 HeapFree(GetProcessHeap(), 0, pszIconPathW);
1290
1291 return hr;
1292}

Referenced by GetIconLocation().

◆ GetIconLocation() [2/4]

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

Definition at line 1656 of file CShellLink.cpp.

1657{
1658 TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1659
1660 if (cchIconPath)
1661 *pszIconPath = 0;
1662
1663 *piIcon = 0;
1664
1665 /* Update the original icon path location */
1667 {
1669
1670 /* Search for an icon environment block */
1671 LPEXP_SZ_LINK pInfo;
1673 if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1674 {
1676
1677 m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
1679
1681 if (!m_sIcoPath)
1682 return E_OUTOFMEMORY;
1683
1685
1686 m_bDirty = TRUE;
1687 }
1688 }
1689
1690 *piIcon = m_Header.nIconIndex;
1691
1692 if (m_sIcoPath)
1693 lstrcpynW(pszIconPath, m_sIcoPath, cchIconPath);
1694
1695 return S_OK;
1696}
LPCWSTR szPath
Definition: env.c:37
@ SLDF_HAS_EXP_ICON_SZ
Definition: shlobj.h:1959
@ SLDF_HAS_ICONLOCATION
Definition: shlobj.h:1949
#define EXP_SZ_ICON_SIG
Definition: shlobj.h:2058
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 1294 of file CShellLink.cpp.

1295{
1296 HRESULT hr;
1297 LPWSTR pszIconFileW;
1298
1299 TRACE("(%p)->(%u %p len=%u piIndex=%p pwFlags=%p)\n", this, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1300
1301 /* Allocate a temporary UNICODE buffer */
1302 pszIconFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR));
1303 if (!pszIconFileW)
1304 return E_OUTOFMEMORY;
1305
1306 /* Call the UNICODE function */
1307 hr = GetIconLocation(uFlags, pszIconFileW, cchMax, piIndex, pwFlags);
1308
1309 /* Convert the file path back to ANSI */
1310 WideCharToMultiByte(CP_ACP, 0, pszIconFileW, -1,
1311 pszIconFile, cchMax, NULL, NULL);
1312
1313 /* Free the temporary buffer */
1314 HeapFree(GetProcessHeap(), 0, pszIconFileW);
1315
1316 return hr;
1317}
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 1720 of file CShellLink.cpp.

1721{
1722 HRESULT hr;
1723
1724 pszIconFile[0] = UNICODE_NULL;
1725
1726 /*
1727 * It is possible for a shell link to point to another shell link,
1728 * and in particular there is the possibility to point to itself.
1729 * Now, suppose we ask such a link to retrieve its associated icon.
1730 * This function would be called, and due to COM would be called again
1731 * recursively. To solve this issue, we forbid calling GetIconLocation()
1732 * with GIL_FORSHORTCUT set in uFlags, as done by Windows (shown by tests).
1733 */
1734 if (uFlags & GIL_FORSHORTCUT)
1735 return E_INVALIDARG;
1736
1737 /*
1738 * Now, we set GIL_FORSHORTCUT so that: i) we allow the icon extractor
1739 * of the target to give us a suited icon, and ii) we protect ourselves
1740 * against recursive call.
1741 */
1742 uFlags |= GIL_FORSHORTCUT;
1743
1744 if (uFlags & GIL_DEFAULTICON)
1745 return S_FALSE;
1746
1747 hr = GetIconLocation(pszIconFile, cchMax, piIndex);
1748 if (FAILED(hr) || pszIconFile[0] == UNICODE_NULL)
1749 {
1750 hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
1751 }
1752 else
1753 {
1754 *pwFlags = GIL_NOTFILENAME | GIL_PERCLASS;
1755 }
1756
1757 return hr;
1758}
#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 1119 of file CShellLink.cpp.

1120{
1121 TRACE("(%p)->(ppidl=%p)\n", this, ppidl);
1122
1123 if (!m_pPidl)
1124 {
1125 *ppidl = NULL;
1126 return S_FALSE;
1127 }
1128
1129 *ppidl = ILClone(m_pPidl);
1130 return S_OK;
1131}
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237

◆ GetPath() [1/2]

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

Definition at line 1070 of file CShellLink.cpp.

1071{
1072 HRESULT hr;
1073 LPWSTR pszFileW;
1074 WIN32_FIND_DATAW wfd;
1075
1076 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1077 this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1078
1079 /* Allocate a temporary UNICODE buffer */
1080 pszFileW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchMaxPath * sizeof(WCHAR));
1081 if (!pszFileW)
1082 return E_OUTOFMEMORY;
1083
1084 /* Call the UNICODE function */
1085 hr = GetPath(pszFileW, cchMaxPath, &wfd, fFlags);
1086
1087 /* Convert the file path back to ANSI */
1088 WideCharToMultiByte(CP_ACP, 0, pszFileW, -1,
1089 pszFile, cchMaxPath, NULL, NULL);
1090
1091 /* Free the temporary buffer */
1092 HeapFree(GetProcessHeap(), 0, pszFileW);
1093
1094 if (pfd)
1095 {
1096 ZeroMemory(pfd, sizeof(*pfd));
1097
1098 /* Copy the file data if a file path was returned */
1099 if (*pszFile)
1100 {
1101 DWORD len;
1102
1103 /* Copy the fixed part */
1104 CopyMemory(pfd, &wfd, FIELD_OFFSET(WIN32_FIND_DATAA, cFileName));
1105
1106 /* Convert the file names to ANSI */
1107 len = lstrlenW(wfd.cFileName);
1108 WideCharToMultiByte(CP_ACP, 0, wfd.cFileName, len + 1,
1109 pfd->cFileName, sizeof(pfd->cFileName), NULL, NULL);
1110 len = lstrlenW(wfd.cAlternateFileName);
1111 WideCharToMultiByte(CP_ACP, 0, wfd.cAlternateFileName, len + 1,
1112 pfd->cAlternateFileName, sizeof(pfd->cAlternateFileName), NULL, NULL);
1113 }
1114 }
1115
1116 return hr;
1117}
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67

Referenced by GetPath().

◆ GetPath() [2/2]

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

Definition at line 1484 of file CShellLink.cpp.

1485{
1487
1488 TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
1489 this, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(m_sPath));
1490
1491 if (cchMaxPath)
1492 *pszFile = 0;
1493 // FIXME: What if cchMaxPath == 0 , or pszFile == NULL ??
1494
1495 // FIXME: What about Darwin??
1496
1497 /*
1498 * Retrieve the path to the target from the PIDL (if we have one).
1499 * NOTE: Do NOT use the cached path (m_sPath from link info).
1500 */
1502 {
1503 if (fFlags & SLGP_SHORTPATH)
1505 // FIXME: Add support for SLGP_UNCPRIORITY
1506 }
1507 else
1508 {
1509 *buffer = 0;
1510 }
1511
1512 /* If we have a FindData structure, initialize it */
1513 if (pfd)
1514 {
1515 ZeroMemory(pfd, sizeof(*pfd));
1516
1517 /* Copy the file data if the target is a file path */
1518 if (*buffer)
1519 {
1520 pfd->dwFileAttributes = m_Header.dwFileAttributes;
1521 pfd->ftCreationTime = m_Header.ftCreationTime;
1522 pfd->ftLastAccessTime = m_Header.ftLastAccessTime;
1523 pfd->ftLastWriteTime = m_Header.ftLastWriteTime;
1524 pfd->nFileSizeHigh = 0;
1525 pfd->nFileSizeLow = m_Header.nFileSizeLow;
1526
1527 /*
1528 * Build temporarily a short path in pfd->cFileName (of size MAX_PATH),
1529 * then extract and store the short file name in pfd->cAlternateFileName.
1530 */
1531 GetShortPathNameW(buffer, pfd->cFileName, _countof(pfd->cFileName));
1532 lstrcpynW(pfd->cAlternateFileName,
1533 PathFindFileNameW(pfd->cFileName),
1534 _countof(pfd->cAlternateFileName));
1535
1536 /* Now extract and store the long file name in pfd->cFileName */
1537 lstrcpynW(pfd->cFileName,
1539 _countof(pfd->cFileName));
1540 }
1541 }
1542
1543 /* Finally check if we have a raw path the user actually wants to retrieve */
1544 if ((fFlags & SLGP_RAWPATH) && (m_Header.dwFlags & SLDF_HAS_EXP_SZ))
1545 {
1546 /* Search for a target environment block */
1547 LPEXP_SZ_LINK pInfo;
1549 if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1550 lstrcpynW(buffer, pInfo->szwTarget, cchMaxPath);
1551 }
1552
1553 /* For diagnostics purposes only... */
1554 // NOTE: SLGP_UNCPRIORITY is unsupported
1555 fFlags &= ~(SLGP_RAWPATH | SLGP_SHORTPATH);
1556 if (fFlags) FIXME("(%p): Unsupported flags %lu\n", this, fFlags);
1557
1558 /* Copy the data back to the user */
1559 if (*buffer)
1560 lstrcpynW(pszFile, buffer, cchMaxPath);
1561
1562 return (*buffer ? S_OK : S_FALSE);
1563}
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:1342
#define EXP_SZ_LINK_SIG
Definition: shlobj.h:2050
@ SLDF_HAS_EXP_SZ
Definition: shlobj.h:1952

◆ GetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::GetShowCmd ( INT piShowCmd)
override

Definition at line 1252 of file CShellLink.cpp.

1253{
1254 TRACE("(%p)->(%p) %d\n", this, piShowCmd, m_Header.nShowCommand);
1255 *piShowCmd = m_Header.nShowCommand;
1256 return S_OK;
1257}

◆ GetSite()

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

Definition at line 3057 of file CShellLink.cpp.

3058{
3059 TRACE("%p %s %p\n", this, debugstr_guid(&iid), ppvSite);
3060
3061 if (m_site == NULL)
3062 return E_FAIL;
3063
3064 return m_site->QueryInterface(iid, ppvSite);
3065}
#define debugstr_guid
Definition: kernel32.h:35

◆ GetSizeMax()

HRESULT STDMETHODCALLTYPE CShellLink::GetSizeMax ( ULARGE_INTEGER pcbSize)
override

Implements IPersistStream.

Definition at line 1002 of file CShellLink.cpp.

1003{
1004 TRACE("(%p)\n", this);
1005 return E_NOTIMPL;
1006}

◆ GetWorkingDirectory() [1/2]

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

Definition at line 1171 of file CShellLink.cpp.

1172{
1173 TRACE("(%p)->(%p len=%u)\n", this, pszDir, cchMaxPath);
1174
1175 if (cchMaxPath)
1176 *pszDir = 0;
1177
1178 if (m_sWorkDir)
1180 pszDir, cchMaxPath, NULL, NULL);
1181
1182 return S_OK;
1183}
_In_ LPCSTR pszDir
Definition: shellapi.h:584

◆ GetWorkingDirectory() [2/2]

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

Definition at line 1594 of file CShellLink.cpp.

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

◆ Initialize()

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

Implements IShellExtInit.

Definition at line 2466 of file CShellLink.cpp.

2467{
2468 TRACE("%p %p %p %p\n", this, pidlFolder, pdtobj, hkeyProgID);
2469
2470 if (!pdtobj)
2471 return E_FAIL;
2472
2473 FORMATETC format;
2474 format.cfFormat = CF_HDROP;
2475 format.ptd = NULL;
2476 format.dwAspect = DVASPECT_CONTENT;
2477 format.lindex = -1;
2478 format.tymed = TYMED_HGLOBAL;
2479
2480 STGMEDIUM stgm;
2481 HRESULT hr = pdtobj->GetData(&format, &stgm);
2482 if (FAILED(hr))
2483 return hr;
2484
2485 UINT count = DragQueryFileW((HDROP)stgm.hGlobal, -1, NULL, 0);
2486 if (count == 1)
2487 {
2488 count = DragQueryFileW((HDROP)stgm.hGlobal, 0, NULL, 0);
2489 count++;
2490 LPWSTR path = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR));
2491 if (path)
2492 {
2493 count = DragQueryFileW((HDROP)stgm.hGlobal, 0, path, count);
2494 hr = Load(path, 0);
2496 }
2497 }
2498 ReleaseStgMedium(&stgm);
2499
2500 return S_OK;
2501}
#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
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)

◆ InvokeCommand()

HRESULT STDMETHODCALLTYPE CShellLink::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
override

Implements IContextMenu.

Definition at line 2561 of file CShellLink.cpp.

2562{
2563 TRACE("%p %p\n", this, lpici);
2564
2565 if (lpici->cbSize < sizeof(CMINVOKECOMMANDINFO))
2566 return E_INVALIDARG;
2567
2568 // NOTE: We could use lpici->hwnd (certainly in case lpici->fMask doesn't contain CMIC_MASK_FLAG_NO_UI)
2569 // as the parent window handle... ?
2570 /* FIXME: get using interface set from IObjectWithSite?? */
2571 // NOTE: We might need an extended version of Resolve that provides us with paths...
2572 HRESULT hr = Resolve(lpici->hwnd, 0);
2573 if (FAILED(hr))
2574 {
2575 TRACE("failed to resolve component error 0x%08x\n", hr);
2576 return hr;
2577 }
2578
2579 UINT idCmd = LOWORD(lpici->lpVerb);
2580 TRACE("idCmd: %d\n", idCmd);
2581
2582 switch (idCmd)
2583 {
2584 case IDCMD_OPEN:
2585 return DoOpen(lpici);
2587 return DoOpenFileLocation();
2588 default:
2589 return E_NOTIMPL;
2590 }
2591}
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
749 if (TRACE_ON(shell))
750 {
751#if (NTDDI_VERSION < NTDDI_LONGHORN)
753 {
754 hr = GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
755 if (SUCCEEDED(hr))
756 TRACE("Product -> %s\n", debugstr_w(sProduct));
757 }
758#endif
760 {
762 if (SUCCEEDED(hr))
763 TRACE("Component -> %s\n", debugstr_w(sComponent));
764 }
765 }
766
768 m_bRunAs = TRUE;
769 else
770 m_bRunAs = FALSE;
771
772 TRACE("OK\n");
773
774 pdump(m_pPidl);
775
776 return S_OK;
777}
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
HRESULT WINAPI ILLoadFromStream(IStream *pStream, LPITEMIDLIST *ppPidl)
Definition: pidl.c:293
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define EXP_DARWIN_ID_SIG
Definition: shlobj.h:2054
@ SLDF_HAS_RELPATH
Definition: shlobj.h:1946
@ SLDF_HAS_ID_LIST
Definition: shlobj.h:1943
@ SLDF_HAS_DARWINID
Definition: shlobj.h:1957
@ SLDF_HAS_LINK_INFO
Definition: shlobj.h:1944
@ SLDF_HAS_WORKINGDIR
Definition: shlobj.h:1947
@ SLDF_HAS_ARGS
Definition: shlobj.h:1948
@ SLDF_FORCE_NO_LINKINFO
Definition: shlobj.h:1951
@ SLDF_RUNAS_USER
Definition: shlobj.h:1958
@ SLDF_UNICODE
Definition: shlobj.h:1950
@ SLDF_HAS_NAME
Definition: shlobj.h:1945
#define PathRemoveBackslash
Definition: shlwapi.h:1023
uint32_t ULONG
Definition: typedefs.h:59
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define DATE_SHORTDATE
Definition: winnls.h:196

◆ 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 
)

FIXME open target directory

Definition at line 2844 of file CShellLink.cpp.

2845{
2846 switch (id)
2847 {
2848 case IDC_SHORTCUT_FIND:
2854 return;
2855
2857 {
2858 WCHAR wszPath[MAX_PATH] = L"";
2859
2860 if (m_sIcoPath)
2861 wcscpy(wszPath, m_sIcoPath);
2862 else
2863 FindExecutableW(m_sPath, NULL, wszPath);
2864
2866 if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
2867 {
2868 SetIconLocation(wszPath, IconIndex);
2869 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2870
2871 HICON hIconLarge = CreateShortcutIcon(wszPath, IconIndex);
2872 if (hIconLarge)
2873 {
2874 if (m_hIcon)
2876 m_hIcon = hIconLarge;
2878 }
2879 }
2880 return;
2881 }
2882
2884 {
2886 if (result == 1 || result == 0)
2887 {
2888 if (m_bRunAs != result)
2889 {
2890 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2891 }
2892
2893 m_bRunAs = result;
2894 }
2895 return;
2896 }
2897 }
2898 if (codeNotify == EN_CHANGE || codeNotify == CBN_SELCHANGE)
2899 {
2900 if (!m_bInInit)
2901 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2902 }
2903}
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:1270
EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD dwFlags)
Definition: shlfolder.cpp:409
#define IDC_SHORTCUT_FIND
Definition: shresdef.h:479
#define IDC_SHORTCUT_ADVANCED
Definition: shresdef.h:481
#define IDC_SHORTCUT_ICON
Definition: shresdef.h:463
#define IDC_SHORTCUT_CHANGE_ICON
Definition: shresdef.h:480
#define IDD_SHORTCUT_EXTENDED_PROPERTIES
Definition: shresdef.h:410
UINT_PTR WPARAM
Definition: windef.h:207
#define STM_SETICON
Definition: winuser.h:2092
#define CBN_SELCHANGE
Definition: winuser.h:1979
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:2022

◆ OnDestroy()

void CShellLink::OnDestroy ( HWND  hwndDlg)

Definition at line 2973 of file CShellLink.cpp.

2974{
2975 if (m_hIcon)
2976 {
2978 m_hIcon = NULL;
2979 }
2980}

◆ OnInitDialog()

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

Definition at line 2745 of file CShellLink.cpp.

2746{
2747 TRACE("CShellLink::OnInitDialog(hwnd %p hwndFocus %p lParam %p)\n", hwndDlg, hwndFocus, lParam);
2748
2750
2751 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,
2753
2754 m_bInInit = TRUE;
2755
2756 /* Get file information */
2757 // FIXME! FIXME! Shouldn't we use m_sIcoPath, m_Header.nIconIndex instead???
2758 SHFILEINFOW fi;
2759 if (!SHGetFileInfoW(m_sLinkPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_ICON))
2760 {
2761 ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_sLinkPath, GetLastError());
2762 fi.szTypeName[0] = L'\0';
2763 fi.hIcon = NULL;
2764 }
2765
2766 if (fi.hIcon)
2767 {
2768 if (m_hIcon)
2770 m_hIcon = fi.hIcon;
2772 }
2773 else
2774 ERR("ExtractIconW failed %ls %u\n", m_sIcoPath, m_Header.nIconIndex);
2775
2776 /* Target type */
2777 if (m_sPath)
2779
2780 /* Target location */
2781 if (m_sPath)
2782 {
2787 }
2788
2789 /* Target path */
2790 if (m_sPath)
2791 {
2792 WCHAR newpath[2*MAX_PATH] = L"\0";
2793 if (wcschr(m_sPath, ' '))
2794 StringCchPrintfExW(newpath, _countof(newpath), NULL, NULL, 0, L"\"%ls\"", m_sPath);
2795 else
2796 StringCchCopyExW(newpath, _countof(newpath), m_sPath, NULL, NULL, 0);
2797
2798 if (m_sArgs && m_sArgs[0])
2799 {
2800 StringCchCatW(newpath, _countof(newpath), L" ");
2801 StringCchCatW(newpath, _countof(newpath), m_sArgs);
2802 }
2803 SetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, newpath);
2804 }
2805
2806 /* Working dir */
2807 if (m_sWorkDir)
2809
2810 /* Description */
2811 if (m_sDescription)
2813
2814 /* Hot key */
2816
2817 /* Run */
2819 const DWORD runshowcmd[] = { SW_SHOWNORMAL, SW_SHOWMINNOACTIVE, SW_SHOWMAXIMIZED };
2820 HWND hRunCombo = GetDlgItem(hwndDlg, IDC_SHORTCUT_RUN_COMBO);
2821 for (UINT i = 0; i < _countof(runstrings); ++i)
2822 {
2824 if (!LoadStringW(shell32_hInstance, runstrings[i], buf, _countof(buf)))
2825 break;
2826
2827 int index = SendMessageW(hRunCombo, CB_ADDSTRING, 0, (LPARAM)buf);
2828 if (index < 0)
2829 continue;
2830 SendMessageW(hRunCombo, CB_SETITEMDATA, index, runshowcmd[i]);
2831 if (!i || m_Header.nShowCommand == runshowcmd[i])
2832 SendMessageW(hRunCombo, CB_SETCURSEL, index, 0);
2833 }
2834
2835 /* auto-completion */
2838
2839 m_bInInit = FALSE;
2840
2841 return TRUE;
2842}
#define wcschr
Definition: compat.h:17
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 HKM_SETHOTKEY
Definition: commctrl.h:2231
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:415
#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:1911
#define IDS_SHORTCUT_RUN_MAX
Definition: shresdef.h:266
#define IDC_SHORTCUT_RUN_COMBO
Definition: shresdef.h:476
#define IDS_SHORTCUT_RUN_MIN
Definition: shresdef.h:265
#define IDC_SHORTCUT_LOCATION_EDIT
Definition: shresdef.h:468
#define IDC_SHORTCUT_TARGET_TEXT
Definition: shresdef.h:470
#define IDC_SHORTCUT_KEY_HOTKEY
Definition: shresdef.h:474
#define IDS_SHORTCUT_RUN_NORMAL
Definition: shresdef.h:264
#define IDC_SHORTCUT_TYPE_EDIT
Definition: shresdef.h:466
#define IDC_SHORTCUT_COMMENT_EDIT
Definition: shresdef.h:478
#define IDC_SHORTCUT_START_IN_EDIT
Definition: shresdef.h:472
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
HICON hIcon
Definition: shellapi.h:372
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SW_SHOWMAXIMIZED
Definition: winuser.h:773
#define CB_SETITEMDATA
Definition: winuser.h:1966
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:1961
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CB_ADDSTRING
Definition: winuser.h:1936
#define SW_SHOWMINNOACTIVE
Definition: winuser.h:777
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ OnNotify()

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

Definition at line 2905 of file CShellLink.cpp.

2906{
2907 WCHAR wszBuf[MAX_PATH];
2908 LPPSHNOTIFY lppsn = (LPPSHNOTIFY)pnmhdr;
2909
2910 if (lppsn->hdr.code == PSN_APPLY)
2911 {
2912 /* set working directory */
2913 GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_START_IN_EDIT, wszBuf, _countof(wszBuf));
2914 SetWorkingDirectory(wszBuf);
2915
2916 /* set link destination */
2917 GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf));
2918 LPWSTR lpszArgs = NULL;
2919 LPWSTR unquoted = strdupW(wszBuf);
2920 StrTrimW(unquoted, L" ");
2921
2922 if (!PathFileExistsW(unquoted))
2923 {
2924 lpszArgs = PathGetArgsW(unquoted);
2925 PathRemoveArgsW(unquoted);
2926 StrTrimW(lpszArgs, L" ");
2927 }
2928 if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
2929 PathUnquoteSpacesW(unquoted);
2930
2931 WCHAR *pwszExt = PathFindExtensionW(unquoted);
2932 if (!wcsicmp(pwszExt, L".lnk"))
2933 {
2934 // FIXME load localized error msg
2935 MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR);
2937 return TRUE;
2938 }
2939
2940 if (!PathFileExistsW(unquoted))
2941 {
2942 // FIXME load localized error msg
2943 MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", L"Error", MB_ICONERROR);
2945 return TRUE;
2946 }
2947
2948 SetPath(unquoted);
2949 if (lpszArgs)
2950 SetArguments(lpszArgs);
2951 else
2952 SetArguments(L"\0");
2953
2954 HeapFree(GetProcessHeap(), 0, unquoted);
2955
2957
2959 if (index != CB_ERR)
2960 {
2962 }
2963
2964 TRACE("This %p m_sLinkPath %S\n", this, m_sLinkPath);
2968 return TRUE;
2969 }
2970 return FALSE;
2971}
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
#define wcsicmp
Definition: compat.h:15
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:2232
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1902
#define SHCNF_PATHW
Definition: shlobj.h:1924
NMHDR hdr
Definition: prsht.h:330
UINT code
Definition: winuser.h:3159
#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:2435
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:787
#define CB_GETITEMDATA
Definition: winuser.h:1950
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define CB_GETCURSEL
Definition: winuser.h:1943

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 2503 of file CShellLink.cpp.

2504{
2505 INT id = 0;
2506
2507 m_idCmdFirst = idCmdFirst;
2508
2509 TRACE("%p %p %u %u %u %u\n", this,
2510 hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
2511
2512 if (!hMenu)
2513 return E_INVALIDARG;
2514
2517
2518 MENUITEMINFOW mii;
2519 ZeroMemory(&mii, sizeof(mii));
2520 mii.cbSize = sizeof(mii);
2522 mii.dwTypeData = strOpen.GetBuffer();
2523 mii.cch = wcslen(mii.dwTypeData);
2524 mii.wID = idCmdFirst + id++;
2526 mii.fType = MFT_STRING;
2527 if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2528 return E_FAIL;
2529
2531 mii.dwTypeData = strOpenFileLoc.GetBuffer();
2532 mii.cch = wcslen(mii.dwTypeData);
2533 mii.wID = idCmdFirst + id++;
2534 mii.fState = MFS_ENABLED;
2535 mii.fType = MFT_STRING;
2536 if (!InsertMenuItemW(hMenu, indexMenu++, TRUE, &mii))
2537 return E_FAIL;
2538
2539 UNREFERENCED_PARAMETER(indexMenu);
2540
2541 return MAKE_HRESULT(SEVERITY_SUCCESS, 0, id);
2542}
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IDS_OPEN_VERB
Definition: shresdef.h:215
#define IDS_OPENFILELOCATION
Definition: shresdef.h:249
LPWSTR dwTypeData
Definition: winuser.h:3269
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define MIIM_ID
Definition: winuser.h:722
#define MIIM_STATE
Definition: winuser.h:721
#define MFS_DEFAULT
Definition: winuser.h:748
#define MFS_ENABLED
Definition: winuser.h:750
#define MFT_STRING
Definition: winuser.h:746
#define MIIM_TYPE
Definition: winuser.h:725
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)

◆ RemoveDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::RemoveDataBlock ( DWORD  dwSig)
override

Implements IShellLinkDataList.

Definition at line 2432 of file CShellLink.cpp.

2433{
2434 if (SHRemoveDataBlock(&m_pDBList, dwSig))
2435 {
2436 m_bDirty = TRUE;
2437 return S_OK;
2438 }
2439 return S_FALSE;
2440}
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 3042 of file CShellLink.cpp.

3043{
3044 TRACE("(%p) (uPageID %u, pfnReplacePage %p lParam %p\n", this, uPageID, pfnReplacePage, lParam);
3045 return E_NOTIMPL;
3046}

◆ 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 1398 of file CShellLink.cpp.

1399{
1400 HRESULT hr = S_OK;
1401 BOOL bSuccess;
1402
1403 TRACE("(%p)->(hwnd=%p flags=%x)\n", this, hwnd, fFlags);
1404
1405 /* FIXME: use IResolveShellLink interface? */
1406
1407 // FIXME: See InvokeCommand().
1408
1409#if (NTDDI_VERSION < NTDDI_LONGHORN)
1410 // NOTE: For Logo3 (EXP_LOGO3_ID_SIG), check also for SHRestricted(REST_NOLOGO3CHANNELNOTIFY)
1412 {
1413 FIXME("Logo3 links are not supported yet!\n");
1414 return E_FAIL;
1415 }
1416#endif
1417
1418 /* Resolve Darwin (MSI) target */
1420 {
1421 LPWSTR component = NULL;
1422 hr = GetAdvertiseInfo(&component, EXP_DARWIN_ID_SIG);
1423 if (FAILED(hr))
1424 return E_FAIL;
1425
1426 /* Clear the cached path */
1429 if (!m_sPath)
1430 return E_FAIL;
1431 }
1432
1433 if (!m_sPath && m_pPidl)
1434 {
1436
1438 if (bSuccess && *buffer)
1439 {
1441 if (!m_sPath)
1442 return E_OUTOFMEMORY;
1443
1444 m_bDirty = TRUE;
1445 }
1446 else
1447 {
1448 hr = S_OK; /* don't report an error occurred while just caching information */
1449 }
1450 }
1451
1452 // FIXME: Strange to do that here...
1453 if (!m_sIcoPath && m_sPath)
1454 {
1456 if (!m_sIcoPath)
1457 return E_OUTOFMEMORY;
1458
1459 m_Header.nIconIndex = 0;
1460
1461 m_bDirty = TRUE;
1462 }
1463
1464 return hr;
1465}
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 878 of file CShellLink.cpp.

879{
880 TRACE("%p %p %x\n", this, stm, fClearDirty);
881
882 m_Header.dwSize = sizeof(m_Header);
883 m_Header.clsid = CLSID_ShellLink;
884
885 /*
886 * Reset the flags: keep only the flags related to data blocks as they were
887 * already set in accordance by the different mutator member functions.
888 * The other flags will be determined now by the presence or absence of data.
889 */
892#if (NTDDI_VERSION < NTDDI_LONGHORN)
894#endif
896 // TODO: When we will support Vista+ functionality, add other flags to this list.
897
898 /* The stored strings are in UNICODE */
900
901 if (m_pPidl)
903 if (m_sPath)
907 if (m_sPathRel && *m_sPathRel)
909 if (m_sWorkDir && *m_sWorkDir)
911 if (m_sArgs && *m_sArgs)
913 if (m_sIcoPath && *m_sIcoPath)
915 if (m_bRunAs)
917
918 /* Write the shortcut header */
919 ULONG count;
920 HRESULT hr = stm->Write(&m_Header, sizeof(m_Header), &count);
921 if (FAILED(hr))
922 {
923 ERR("Write failed\n");
924 return hr;
925 }
926
927 /* Save the data in order */
928
929 if (m_pPidl)
930 {
931 hr = ILSaveToStream(stm, m_pPidl);
932 if (FAILED(hr))
933 {
934 ERR("Failed to write PIDL\n");
935 return hr;
936 }
937 }
938
939 if (m_sPath)
940 {
942 if (FAILED(hr))
943 return hr;
944 }
945
947 {
949 if (FAILED(hr))
950 return hr;
951 }
952
954 {
956 if (FAILED(hr))
957 return hr;
958 }
959
961 {
963 if (FAILED(hr))
964 return hr;
965 }
966
968 {
970 if (FAILED(hr))
971 return hr;
972 }
973
975 {
977 if (FAILED(hr))
978 return hr;
979 }
980
981 /*
982 * Now save the data block list.
983 *
984 * NOTE that both advertised Product and Component are already saved
985 * inside Logo3 and Darwin data blocks in the m_pDBList list, and the
986 * m_Header.dwFlags is suitably initialized.
987 */
989 if (FAILED(hr))
990 return hr;
991
992 /* Clear the dirty bit if requested */
993 if (fClearDirty)
994 m_bDirty = FALSE;
995
996 return hr;
997}
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:1953
@ SLDF_RUN_WITH_SHIMLAYER
Definition: shlobj.h:1962

◆ 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:1890

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 2105 of file CShellLink.cpp.

2106{
2107 HRESULT hr;
2108 LPCWSTR szComponent = NULL, szProduct = NULL, p;
2109 INT len;
2110 GUID guid;
2111 WCHAR szGuid[38+1];
2112
2114
2115 while (str[0])
2116 {
2117 /* each segment must start with two colons */
2118 if (str[0] != ':' || str[1] != ':')
2119 return E_FAIL;
2120
2121 /* the last segment is just two colons */
2122 if (!str[2])
2123 break;
2124 str += 2;
2125
2126 /* there must be a colon straight after a guid */
2127 p = wcschr(str, L':');
2128 if (!p)
2129 return E_FAIL;
2130 len = p - str;
2131 if (len != 38)
2132 return E_FAIL;
2133
2134 /* get the guid, and check if it's validly formatted */
2135 memcpy(szGuid, str, sizeof(WCHAR)*len);
2136 szGuid[len] = 0;
2137
2139 if (hr != S_OK)
2140 return hr;
2141 str = p + 1;
2142
2143 /* match it up to a guid that we care about */
2144 if (IsEqualGUID(guid, SHELL32_AdvtShortcutComponent) && !szComponent)
2145 szComponent = str; /* Darwin */
2146 else if (IsEqualGUID(guid, SHELL32_AdvtShortcutProduct) && !szProduct)
2147 szProduct = str; /* Logo3 */
2148 else
2149 return E_FAIL;
2150
2151 /* skip to the next field */
2152 str = wcschr(str, L':');
2153 if (!str)
2154 return E_FAIL;
2155 }
2156
2157 /* we have to have a component for an advertised shortcut */
2158 if (!szComponent)
2159 return E_FAIL;
2160
2161 szComponent = GetAdvertisedArg(szComponent);
2162 szProduct = GetAdvertisedArg(szProduct);
2163
2164 hr = WriteAdvertiseInfo(szComponent, EXP_DARWIN_ID_SIG);
2165 // if (FAILED(hr))
2166 // return hr;
2167#if (NTDDI_VERSION < NTDDI_LONGHORN)
2168 hr = WriteAdvertiseInfo(szProduct, EXP_LOGO3_ID_SIG);
2169 // if (FAILED(hr))
2170 // return hr;
2171#endif
2172
2173 HeapFree(GetProcessHeap(), 0, (PVOID)szComponent);
2174 HeapFree(GetProcessHeap(), 0, (PVOID)szProduct);
2175
2176 if (TRACE_ON(shell))
2177 {
2179 TRACE("Component = %s\n", debugstr_w(sComponent));
2180#if (NTDDI_VERSION < NTDDI_LONGHORN)
2181 GetAdvertiseInfo(&sProduct, EXP_LOGO3_ID_SIG);
2182 TRACE("Product = %s\n", debugstr_w(sProduct));
2183#endif
2184 }
2185
2186 return S_OK;
2187}
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 1217 of file CShellLink.cpp.

1218{
1219 TRACE("(%p)->(args=%s)\n", this, pszArgs);
1220
1222 m_sArgs = NULL;
1223
1224 if (pszArgs)
1225 {
1226 m_sArgs = HEAP_strdupAtoW(GetProcessHeap(), 0, pszArgs);
1227 if (!m_sArgs)
1228 return E_OUTOFMEMORY;
1229 }
1230 m_bDirty = TRUE;
1231
1232 return S_OK;
1233}

Referenced by OnNotify().

◆ SetArguments() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCWSTR  pszArgs)
override

Implements IShellLinkW.

Definition at line 1638 of file CShellLink.cpp.

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

◆ SetDescription() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCSTR  pszName)
override

Implements IShellLinkA.

Definition at line 1153 of file CShellLink.cpp.

1154{
1155 TRACE("(%p)->(pName=%s)\n", this, pszName);
1156
1159
1160 if (pszName)
1161 {
1163 if (!m_sDescription)
1164 return E_OUTOFMEMORY;
1165 }
1166 m_bDirty = TRUE;
1167
1168 return S_OK;
1169}

◆ SetDescription() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCWSTR  pszName)
override

Implements IShellLinkW.

Definition at line 1576 of file CShellLink.cpp.

1577{
1578 TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
1579
1582
1583 if (pszName)
1584 {
1585 m_sDescription = strdupW(pszName);
1586 if (!m_sDescription)
1587 return E_OUTOFMEMORY;
1588 }
1589 m_bDirty = TRUE;
1590
1591 return S_OK;
1592}

◆ SetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::SetFlags ( DWORD  dwFlags)
override

Implements IShellLinkDataList.

Definition at line 2449 of file CShellLink.cpp.

2450{
2451#if 0 // FIXME!
2453 m_bDirty = TRUE;
2454 return S_OK;
2455#else
2456 FIXME("\n");
2457 return E_NOTIMPL;
2458#endif
2459}
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ SetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::SetHotkey ( WORD  wHotkey)
override

Implements IShellLinkA.

Definition at line 1242 of file CShellLink.cpp.

1243{
1244 TRACE("(%p)->(hotkey=%x)\n", this, wHotkey);
1245
1246 m_Header.wHotKey = wHotkey;
1247 m_bDirty = TRUE;
1248
1249 return S_OK;
1250}

◆ SetIconLocation() [1/2]

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

Definition at line 1339 of file CShellLink.cpp.

1340{
1341 TRACE("(%p)->(path=%s iicon=%u)\n", this, pszIconPath, iIcon);
1342
1343 LPWSTR str = NULL;
1344 if (pszIconPath)
1345 {
1346 str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
1347 if (!str)
1348 return E_OUTOFMEMORY;
1349 }
1350
1351 HRESULT hr = SetIconLocation(str, iIcon);
1352
1353 if (str)
1355
1356 return hr;
1357}

Referenced by OnCommand(), and SetIconLocation().

◆ SetIconLocation() [2/2]

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

Definition at line 1876 of file CShellLink.cpp.

1877{
1878 HRESULT hr = E_FAIL;
1879 WCHAR szIconPath[MAX_PATH];
1880
1881 TRACE("(%p)->(path=%s iicon=%u)\n", this, debugstr_w(pszIconPath), iIcon);
1882
1883 if (pszIconPath)
1884 {
1885 /*
1886 * Check whether the user-given file path contains unexpanded
1887 * environment variables. If so, create a target environment block.
1888 * Note that in this block we will store the user-given path.
1889 * It will contain the unexpanded environment variables, but
1890 * it can also contain already expanded path that the user does
1891 * not want to see them unexpanded (e.g. so that they always
1892 * refer to the same place even if the would-be corresponding
1893 * environment variable could change).
1894 */
1895#ifdef ICON_LINK_WINDOWS_COMPAT
1896 /* Try to fully unexpand the icon path */
1897 // if (PathFullyUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath)))
1898 BOOL bSuccess = PathUnExpandEnvStringsW(pszIconPath, szIconPath, _countof(szIconPath));
1899 if (bSuccess && wcscmp(pszIconPath, szIconPath) != 0)
1900#else
1901 /*
1902 * In some situations, described in http://stackoverflow.com/questions/2976489/ishelllinkseticonlocation-translates-my-icon-path-into-program-files-which-i
1903 * the result of PathUnExpandEnvStringsW() could be wrong, and instead
1904 * one would have to store the actual provided icon location path, while
1905 * creating an icon environment block ONLY if that path already contains
1906 * environment variables. This is what the present case is trying to implement.
1907 */
1908 SHExpandEnvironmentStringsW(pszIconPath, szIconPath, _countof(szIconPath));
1909 if (wcscmp(pszIconPath, szIconPath) != 0)
1910#endif
1911 {
1912 /*
1913 * The user-given file path contains unexpanded environment
1914 * variables, so we need an icon environment block.
1915 */
1917 LPEXP_SZ_LINK pInfo;
1918
1919#ifdef ICON_LINK_WINDOWS_COMPAT
1920 /* Make pszIconPath point to the unexpanded path */
1921 LPCWSTR pszOrgIconPath = pszIconPath;
1922 pszIconPath = szIconPath;
1923#endif
1925 if (pInfo)
1926 {
1927 /* Make sure that the size of the structure is valid */
1928 if (pInfo->cbSize != sizeof(*pInfo))
1929 {
1930 ERR("Ooops. This structure is not as expected...\n");
1931
1932 /* Invalid structure, remove it altogether */
1933 m_Header.dwFlags &= ~SLDF_HAS_EXP_ICON_SZ;
1935
1936 /* Reset the pointer and go use the static buffer */
1937 pInfo = NULL;
1938 }
1939 }
1940 if (!pInfo)
1941 {
1942 /* Use the static buffer */
1943 pInfo = &buffer;
1944 buffer.cbSize = sizeof(buffer);
1945 buffer.dwSignature = EXP_SZ_ICON_SIG;
1946 }
1947
1948 lstrcpynW(pInfo->szwTarget, pszIconPath, _countof(pInfo->szwTarget));
1949 WideCharToMultiByte(CP_ACP, 0, pszIconPath, -1,
1950 pInfo->szTarget, _countof(pInfo->szTarget), NULL, NULL);
1951
1952 hr = S_OK;
1953 if (pInfo == &buffer)
1954 hr = AddDataBlock(pInfo);
1955 if (hr == S_OK)
1957
1958#ifdef ICON_LINK_WINDOWS_COMPAT
1959 /* Set pszIconPath back to the original one */
1960 pszIconPath = pszOrgIconPath;
1961#else
1962 /* Now, make pszIconPath point to the expanded path */
1963 pszIconPath = szIconPath;
1964#endif
1965 }
1966 else
1967 {
1968 /*
1969 * The user-given file path does not contain unexpanded environment
1970 * variables, so we need to remove any icon environment block.
1971 */
1972 m_Header.dwFlags &= ~SLDF_HAS_EXP_ICON_SZ;
1974
1975 /* pszIconPath points to the user path */
1976 }
1977 }
1978
1979#ifdef ICON_LINK_WINDOWS_COMPAT
1980 /* Store the original icon path location (may contain unexpanded environment strings) */
1981#endif
1982 if (pszIconPath)
1983 {
1984 m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
1986
1987 m_sIcoPath = strdupW(pszIconPath);
1988 if (!m_sIcoPath)
1989 return E_OUTOFMEMORY;
1990
1992 }
1993
1994 hr = S_OK;
1995
1996 m_Header.nIconIndex = iIcon;
1997 m_bDirty = TRUE;
1998
1999 return hr;
2000}
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 1133 of file CShellLink.cpp.

1134{
1135 TRACE("(%p)->(pidl=%p)\n", this, pidl);
1136 return SetTargetFromPIDLOrPath(pidl, NULL);
1137}

◆ SetPath() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetPath ( LPCSTR  pszFile)
override

Implements IShellLinkA.

Definition at line 1467 of file CShellLink.cpp.

1468{
1469 TRACE("(%p)->(path=%s)\n", this, pszFile);
1470
1471 if (!pszFile)
1472 return E_INVALIDARG;
1473
1474 LPWSTR str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1475 if (!str)
1476 return E_OUTOFMEMORY;
1477
1478 HRESULT hr = SetPath(str);
1480
1481 return hr;
1482}

Referenced by OnNotify(), and SetPath().

◆ SetPath() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetPath ( LPCWSTR  pszFile)
override

Implements IShellLinkW.

Definition at line 2269 of file CShellLink.cpp.

2270{
2271 LPWSTR unquoted = NULL;
2272 HRESULT hr = S_OK;
2273
2274 TRACE("(%p)->(path=%s)\n", this, debugstr_w(pszFile));
2275
2276 if (!pszFile)
2277 return E_INVALIDARG;
2278
2279 /*
2280 * Allow upgrading Logo3 shortcuts (m_Header.dwFlags & SLDF_HAS_LOGO3ID),
2281 * but forbid upgrading Darwin ones.
2282 */
2284 return S_FALSE;
2285
2286 /* quotes at the ends of the string are stripped */
2287 SIZE_T len = wcslen(pszFile);
2288 if (pszFile[0] == L'"' && pszFile[len-1] == L'"')
2289 {
2290 unquoted = strdupW(pszFile);
2291 PathUnquoteSpacesW(unquoted);
2292 pszFile = unquoted;
2293 }
2294
2295 /* any other quote marks are invalid */
2296 if (wcschr(pszFile, L'"'))
2297 {
2298 hr = S_FALSE;
2299 goto end;
2300 }
2301
2302 /* Clear the cached path */
2304 m_sPath = NULL;
2305
2306 /* Check for an advertised target (Logo3 or Darwin) */
2307 if (SetAdvertiseInfo(pszFile) != S_OK)
2308 {
2309 /* This is not an advertised target, but a regular path */
2311
2312 /*
2313 * Check whether the user-given file path contains unexpanded
2314 * environment variables. If so, create a target environment block.
2315 * Note that in this block we will store the user-given path.
2316 * It will contain the unexpanded environment variables, but
2317 * it can also contain already expanded path that the user does
2318 * not want to see them unexpanded (e.g. so that they always
2319 * refer to the same place even if the would-be corresponding
2320 * environment variable could change).
2321 */
2322 if (*pszFile)
2324 else
2325 *szPath = L'\0';
2326
2327 if (*pszFile && (wcscmp(pszFile, szPath) != 0))
2328 {
2329 /*
2330 * The user-given file path contains unexpanded environment
2331 * variables, so we need a target environment block.
2332 */
2334 LPEXP_SZ_LINK pInfo;
2335
2337 if (pInfo)
2338 {
2339 /* Make sure that the size of the structure is valid */
2340 if (pInfo->cbSize != sizeof(*pInfo))
2341 {
2342 ERR("Ooops. This structure is not as expected...\n");
2343
2344 /* Invalid structure, remove it altogether */
2345 m_Header.dwFlags &= ~SLDF_HAS_EXP_SZ;
2347
2348 /* Reset the pointer and go use the static buffer */
2349 pInfo = NULL;
2350 }
2351 }
2352 if (!pInfo)
2353 {
2354 /* Use the static buffer */
2355 pInfo = &buffer;
2356 buffer.cbSize = sizeof(buffer);
2357 buffer.dwSignature = EXP_SZ_LINK_SIG;
2358 }
2359
2360 lstrcpynW(pInfo->szwTarget, pszFile, _countof(pInfo->szwTarget));
2361 WideCharToMultiByte(CP_ACP, 0, pszFile, -1,
2362 pInfo->szTarget, _countof(pInfo->szTarget), NULL, NULL);
2363
2364 hr = S_OK;
2365 if (pInfo == &buffer)
2366 hr = AddDataBlock(pInfo);
2367 if (hr == S_OK)
2369
2370 /* Now, make pszFile point to the expanded path */
2371 pszFile = szPath;
2372 }
2373 else
2374 {
2375 /*
2376 * The user-given file path does not contain unexpanded environment
2377 * variables, so we need to remove any target environment block.
2378 */
2379 m_Header.dwFlags &= ~SLDF_HAS_EXP_SZ;
2381
2382 /* pszFile points to the user path */
2383 }
2384
2385 /* Set the target */
2386 hr = SetTargetFromPIDLOrPath(NULL, pszFile);
2387 }
2388
2389 m_bDirty = TRUE;
2390
2391end:
2392 HeapFree(GetProcessHeap(), 0, unquoted);
2393 return hr;
2394}
GLuint GLuint end
Definition: gl.h:1545

◆ SetRelativePath() [1/2]

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

Implements IShellLinkA.

Definition at line 1359 of file CShellLink.cpp.

1360{
1361 TRACE("(%p)->(path=%s %x)\n", this, pszPathRel, dwReserved);
1362
1364 m_sPathRel = NULL;
1365
1366 if (pszPathRel)
1367 {
1368 m_sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
1369 m_bDirty = TRUE;
1370 }
1371
1373}
_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 2002 of file CShellLink.cpp.

2003{
2004 TRACE("(%p)->(path=%s %x)\n", this, debugstr_w(pszPathRel), dwReserved);
2005
2007 m_sPathRel = NULL;
2008
2009 if (pszPathRel)
2010 {
2011 m_sPathRel = strdupW(pszPathRel);
2012 if (!m_sPathRel)
2013 return E_OUTOFMEMORY;
2014 }
2015 m_bDirty = TRUE;
2016
2018}

◆ SetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::SetShowCmd ( INT  iShowCmd)
override

Definition at line 1259 of file CShellLink.cpp.

1260{
1261 TRACE("(%p) %d\n", this, iShowCmd);
1262
1263 m_Header.nShowCommand = iShowCmd;
1264 m_bDirty = TRUE;
1265
1266 return S_OK;
1267}

◆ SetSite()

HRESULT STDMETHODCALLTYPE CShellLink::SetSite ( IUnknown punk)
override

Implements IObjectWithSite.

Definition at line 3048 of file CShellLink.cpp.

3049{
3050 TRACE("%p %p\n", this, punk);
3051
3052 m_site = punk;
3053
3054 return S_OK;
3055}

◆ SetTargetFromPIDLOrPath()

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

Definition at line 2189 of file CShellLink.cpp.

2190{
2191 HRESULT hr = S_OK;
2192 LPITEMIDLIST pidlNew = NULL;
2194
2195 /*
2196 * Not both 'pidl' and 'pszFile' should be set.
2197 * But either one or both can be NULL.
2198 */
2199 if (pidl && pszFile)
2200 return E_FAIL;
2201
2202 if (pidl)
2203 {
2204 /* Clone the PIDL */
2205 pidlNew = ILClone(pidl);
2206 if (!pidlNew)
2207 return E_FAIL;
2208 }
2209 else if (pszFile)
2210 {
2211 /* Build a PIDL for this path target */
2212 hr = SHILCreateFromPathW(pszFile, &pidlNew, NULL);
2213 if (FAILED(hr))
2214 {
2215 /* This failed, try to resolve the path, then create a simple PIDL */
2216
2219
2221 {
2222 hr = E_INVALIDARG;
2223 szPath[0] = 0;
2224 }
2225 else
2226 {
2227 hr = S_OK;
2229 // NOTE: Don't make it failed here even if pidlNew was NULL.
2230 // We don't fail on purpose even if SHSimpleIDListFromPathW returns NULL.
2231 // This behaviour has been verified with tests.
2232 }
2233 }
2234 }
2235 // else if (!pidl && !pszFile) { pidlNew = NULL; hr = S_OK; }
2236
2237 ILFree(m_pPidl);
2238 m_pPidl = pidlNew;
2239
2240 if (!pszFile)
2241 {
2242 if (SHGetPathFromIDListW(pidlNew, szPath))
2243 pszFile = szPath;
2244 }
2245
2246 // TODO: Fully update link info, tracker, file attribs...
2247
2248 // if (pszFile)
2249 if (!pszFile)
2250 {
2251 *szPath = L'\0';
2252 pszFile = szPath;
2253 }
2254
2255 /* Update the cached path (for link info) */
2257
2258 if (m_sPath)
2260
2261 m_sPath = strdupW(pszFile);
2262 if (!m_sPath)
2263 return E_OUTOFMEMORY;
2264
2265 m_bDirty = TRUE;
2266 return hr;
2267}
#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:1126
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by SetIDList(), and SetPath().

◆ SetWorkingDirectory() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory ( LPCSTR  pszDir)
override

Implements IShellLinkA.

Definition at line 1185 of file CShellLink.cpp.

1186{
1187 TRACE("(%p)->(dir=%s)\n", this, pszDir);
1188
1190 m_sWorkDir = NULL;
1191
1192 if (pszDir)
1193 {
1195 if (!m_sWorkDir)
1196 return E_OUTOFMEMORY;
1197 }
1198 m_bDirty = TRUE;
1199
1200 return S_OK;
1201}

Referenced by OnNotify().

◆ SetWorkingDirectory() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory ( LPCWSTR  pszDir)
override

Implements IShellLinkW.

Definition at line 1607 of file CShellLink.cpp.

1608{
1609 TRACE("(%p)->(dir=%s)\n", this, debugstr_w(pszDir));
1610
1612 m_sWorkDir = NULL;
1613
1614 if (pszDir)
1615 {
1617 if (!m_sWorkDir)
1618 return E_OUTOFMEMORY;
1619 }
1620 m_bDirty = TRUE;
1621
1622 return S_OK;
1623}

◆ SH_ShellLinkDlgProc()

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

Definition at line 2989 of file CShellLink.cpp.

2990{
2991 LPPROPSHEETPAGEW ppsp;
2992 CShellLink *pThis = reinterpret_cast<CShellLink *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
2993
2994 switch (uMsg)
2995 {
2996 case WM_INITDIALOG:
2997 ppsp = (LPPROPSHEETPAGEW)lParam;
2998 if (ppsp == NULL)
2999 break;
3000
3001 pThis = reinterpret_cast<CShellLink *>(ppsp->lParam);
3002 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pThis);
3003 return pThis->OnInitDialog(hwndDlg, (HWND)(wParam), lParam);
3004
3005 case WM_NOTIFY:
3006 return pThis->OnNotify(hwndDlg, (int)wParam, (NMHDR *)lParam);
3007
3008 case WM_COMMAND:
3009 pThis->OnCommand(hwndDlg, LOWORD(wParam), (HWND)lParam, HIWORD(wParam));
3010 break;
3011
3012 case WM_DESTROY:
3013 pThis->OnDestroy(hwndDlg);
3014 break;
3015
3016 default:
3017 break;
3018 }
3019
3020 return FALSE;
3021}
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:872
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by AddPages().

◆ WriteAdvertiseInfo()

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

Definition at line 2039 of file CShellLink.cpp.

2040{
2042 LPEXP_DARWIN_LINK pInfo;
2043
2044 if ( (dwSig != EXP_DARWIN_ID_SIG)
2046 && (dwSig != EXP_LOGO3_ID_SIG)
2047#endif
2048 )
2049 {
2050 return E_INVALIDARG;
2051 }
2052
2053 if (!string)
2054 return S_FALSE;
2055
2057 if (pInfo)
2058 {
2059 /* Make sure that the size of the structure is valid */
2060 if (pInfo->dbh.cbSize != sizeof(*pInfo))
2061 {
2062 ERR("Ooops. This structure is not as expected...\n");
2063
2064 /* Invalid structure, remove it altogether */
2065 if (dwSig == EXP_DARWIN_ID_SIG)
2066 m_Header.dwFlags &= ~SLDF_HAS_DARWINID;
2067#if (NTDDI_VERSION < NTDDI_LONGHORN)
2068 else if (dwSig == EXP_LOGO3_ID_SIG)
2069 m_Header.dwFlags &= ~SLDF_HAS_LOGO3ID;
2070#endif
2071 RemoveDataBlock(dwSig);
2072
2073 /* Reset the pointer and go use the static buffer */
2074 pInfo = NULL;
2075 }
2076 }
2077 if (!pInfo)
2078 {
2079 /* Use the static buffer */
2080 pInfo = &buffer;
2081 buffer.dbh.cbSize = sizeof(buffer);
2082 buffer.dbh.dwSignature = dwSig;
2083 }
2084
2085 lstrcpynW(pInfo->szwDarwinID, string, _countof(pInfo->szwDarwinID));
2086 WideCharToMultiByte(CP_ACP, 0, string, -1,
2087 pInfo->szDarwinID, _countof(pInfo->szDarwinID), NULL, NULL);
2088
2089 HRESULT hr = S_OK;
2090 if (pInfo == &buffer)
2091 hr = AddDataBlock(pInfo);
2092 if (hr == S_OK)
2093 {
2094 if (dwSig == EXP_DARWIN_ID_SIG)
2096#if (NTDDI_VERSION < NTDDI_LONGHORN)
2097 else if (dwSig == EXP_LOGO3_ID_SIG)
2099#endif
2100 }
2101
2102 return hr;
2103}
#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

◆ m_site

CComPtr<IUnknown> CShellLink::m_site
private

Definition at line 98 of file CShellLink.h.

Referenced by GetSite(), and SetSite().

◆ m_sLinkPath

LPWSTR CShellLink::m_sLinkPath
private

Definition at line 96 of file CShellLink.h.

Referenced by CShellLink(), DoOpen(), GetCurFile(), Load(), OnInitDialog(), OnNotify(), Save(), and ~CShellLink().

◆ m_sPath

◆ m_sPathRel

LPWSTR CShellLink::m_sPathRel
private

Definition at line 81 of file CShellLink.h.

Referenced by CShellLink(), Load(), OnInitDialog(), Reset(), Save(), SetRelativePath(), and ~CShellLink().

◆ m_sWorkDir

LPWSTR CShellLink::m_sWorkDir
private

◆ sComponent

LPWSTR CShellLink::sComponent
private

Definition at line 94 of file CShellLink.h.

Referenced by CShellLink(), Load(), OnInitDialog(), Reset(), and SetAdvertiseInfo().

◆ sProduct

LPWSTR CShellLink::sProduct
private

Definition at line 93 of file CShellLink.h.

Referenced by CShellLink(), Load(), OnInitDialog(), Reset(), and SetAdvertiseInfo().

◆ volume

volume_info CShellLink::volume
private

Definition at line 78 of file CShellLink.h.


The documentation for this class was generated from the following files: