ReactOS  0.4.14-dev-358-gbef841c
CShellLink Class Reference

#include <CShellLink.h>

Inheritance diagram for CShellLink:
Collaboration diagram for CShellLink:

Classes

struct  volume_info
 

Public Types

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

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

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

Detailed Description

Definition at line 28 of file CShellLink.h.

Member Enumeration Documentation

◆ IDCMD

Enumerator
IDCMD_OPEN 
IDCMD_OPENFILELOCATION 

Definition at line 62 of file CShellLink.h.

Constructor & Destructor Documentation

◆ CShellLink()

CShellLink::CShellLink ( )

Definition at line 250 of file CShellLink.cpp.

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

◆ ~CShellLink()

CShellLink::~CShellLink ( )

Definition at line 288 of file CShellLink.cpp.

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

Member Function Documentation

◆ AddDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::AddDataBlock ( void pDataBlock)
virtual

Implements IShellLinkDataList.

Definition at line 2472 of file CShellLink.cpp.

2473 {
2474  if (SHAddDataBlock(&m_pDBList, (DATABLOCK_HEADER*)pDataBlock))
2475  {
2476  m_bDirty = TRUE;
2477  return S_OK;
2478  }
2479  return S_FALSE;
2480 }
#define TRUE
Definition: types.h:120
BOOL WINAPI SHAddDataBlock(LPDBLIST *lppList, const DATABLOCK_HEADER *lpNewItem)
Definition: clist.c:68
#define S_FALSE
Definition: winerror.h:2357
#define S_OK
Definition: intsafe.h:59

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

◆ AddPages()

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

Definition at line 3066 of file CShellLink.cpp.

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

◆ CopyDataBlock()

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

Implements IShellLinkDataList.

Definition at line 2482 of file CShellLink.cpp.

2483 {
2484  DATABLOCK_HEADER* pBlock;
2485  PVOID pDataBlock;
2486 
2487  TRACE("%p %08x %p\n", this, dwSig, ppDataBlock);
2488 
2489  *ppDataBlock = NULL;
2490 
2491  pBlock = SHFindDataBlock(m_pDBList, dwSig);
2492  if (!pBlock)
2493  {
2494  ERR("unknown datablock %08x (not found)\n", dwSig);
2495  return E_FAIL;
2496  }
2497 
2498  pDataBlock = LocalAlloc(LMEM_ZEROINIT, pBlock->cbSize);
2499  if (!pDataBlock)
2500  return E_OUTOFMEMORY;
2501 
2502  CopyMemory(pDataBlock, pBlock, pBlock->cbSize);
2503 
2504  *ppDataBlock = pDataBlock;
2505  return S_OK;
2506 }
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define LMEM_ZEROINIT
Definition: winbase.h:356
#define CopyMemory
Definition: winbase.h:1640
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

◆ CreateShortcutIcon()

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

Definition at line 3194 of file CShellLink.cpp.

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

Referenced by OnCommand().

◆ DoOpen()

HRESULT CShellLink::DoOpen ( LPCMINVOKECOMMANDINFO  lpici)
private

Definition at line 2669 of file CShellLink.cpp.

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

Referenced by InvokeCommand().

◆ DoOpenFileLocation()

HRESULT CShellLink::DoOpenFileLocation ( )
private

Definition at line 2620 of file CShellLink.cpp.

2621 {
2622  WCHAR szParams[MAX_PATH + 64];
2623  StringCbPrintfW(szParams, sizeof(szParams), L"/select,%s", m_sPath);
2624 
2625  INT_PTR ret;
2626  ret = reinterpret_cast<INT_PTR>(ShellExecuteW(NULL, NULL, L"explorer.exe", szParams,
2628  if (ret <= 32)
2629  {
2630  ERR("ret: %08lX\n", ret);
2631  return E_FAIL;
2632  }
2633 
2634  return S_OK;
2635 }
int32_t INT_PTR
Definition: typedefs.h:62
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2246

Referenced by InvokeCommand().

◆ DragEnter()

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

Implements IDropTarget.

Definition at line 3106 of file CShellLink.cpp.

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

◆ DragLeave()

HRESULT STDMETHODCALLTYPE CShellLink::DragLeave ( void  )
virtual

Implements IDropTarget.

Definition at line 3144 of file CShellLink.cpp.

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

◆ DragOver()

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

Implements IDropTarget.

Definition at line 3134 of file CShellLink.cpp.

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

◆ Drop()

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

Implements IDropTarget.

Definition at line 3157 of file CShellLink.cpp.

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

◆ Extract() [1/2]

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

Implements IExtractIconA.

Definition at line 1300 of file CShellLink.cpp.

1301 {
1302  TRACE("(%p)->(path=%s iicon=%u)\n", this, pszFile, nIconIndex);
1303 
1304  LPWSTR str = NULL;
1305  if (pszFile)
1306  {
1307  str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
1308  if (!str)
1309  return E_OUTOFMEMORY;
1310  }
1311 
1312  HRESULT hr = Extract(str, nIconIndex, phiconLarge, phiconSmall, nIconSize);
1313 
1314  if (str)
1315  HeapFree(GetProcessHeap(), 0, str);
1316 
1317  return hr;
1318 }
HRESULT hr
Definition: shlfolder.c:183
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
LONG HRESULT
Definition: typedefs.h:77
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ Extract() [2/2]

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

Definition at line 1742 of file CShellLink.cpp.

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

◆ GetAdvertiseInfo()

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

Definition at line 594 of file CShellLink.cpp.

595 {
596  LPEXP_DARWIN_LINK pInfo;
597 
598  *str = NULL;
599 
601  if (!pInfo)
602  return E_FAIL;
603 
604  /* Make sure that the size of the structure is valid */
605  if (pInfo->dbh.cbSize != sizeof(*pInfo))
606  {
607  ERR("Ooops. This structure is not as expected...\n");
608  return E_FAIL;
609  }
610 
611  TRACE("dwSig %08x string = '%s'\n", pInfo->dbh.dwSignature, debugstr_w(pInfo->szwDarwinID));
612 
613  *str = pInfo->szwDarwinID;
614  return S_OK;
615 }
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
struct EXP_DARWIN_LINK * LPEXP_DARWIN_LINK
#define TRACE(s)
Definition: solgame.cpp:4
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59

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

◆ GetArguments() [1/2]

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

Definition at line 1184 of file CShellLink.cpp.

1185 {
1186  TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1187 
1188  if (cchMaxPath)
1189  *pszArgs = 0;
1190 
1191  if (m_sArgs)
1193  pszArgs, cchMaxPath, NULL, NULL);
1194 
1195  return S_OK;
1196 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetArguments() [2/2]

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

Definition at line 1606 of file CShellLink.cpp.

1607 {
1608  TRACE("(%p)->(%p len=%u)\n", this, pszArgs, cchMaxPath);
1609 
1610  if (cchMaxPath)
1611  *pszArgs = 0;
1612 
1613  if (m_sArgs)
1614  lstrcpynW(pszArgs, m_sArgs, cchMaxPath);
1615 
1616  return S_OK;
1617 }
#define lstrcpynW
Definition: compat.h:405
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetClassID()

HRESULT STDMETHODCALLTYPE CShellLink::GetClassID ( CLSID pclsid)
virtual

Implements IPersist.

Definition at line 305 of file CShellLink.cpp.

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

◆ GetCommandString()

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

Implements IContextMenu.

Definition at line 2728 of file CShellLink.cpp.

2729 {
2730  FIXME("%p %lu %u %p %p %u\n", this, idCmd, uType, pwReserved, pszName, cchMax);
2731  return E_NOTIMPL;
2732 }
#define FIXME(fmt,...)
Definition: debug.h:110
UINT cchMax
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetCurFile()

HRESULT STDMETHODCALLTYPE CShellLink::GetCurFile ( LPOLESTR ppszFileName)
virtual

Implements IPersistFile.

Definition at line 382 of file CShellLink.cpp.

383 {
384  *ppszFileName = NULL;
385 
386  if (!m_sLinkPath)
387  {
388  /* IPersistFile::GetCurFile called before IPersistFile::Save */
389  return S_FALSE;
390  }
391 
392  *ppszFileName = (LPOLESTR)CoTaskMemAlloc((wcslen(m_sLinkPath) + 1) * sizeof(WCHAR));
393  if (!*ppszFileName)
394  {
395  /* out of memory */
396  return E_OUTOFMEMORY;
397  }
398 
399  /* copy last saved filename */
400  wcscpy(*ppszFileName, m_sLinkPath);
401 
402  return S_OK;
403 }
static LPOLESTR
Definition: stg_prop.c:27
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define S_OK
Definition: intsafe.h:59
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ GetDescription() [1/2]

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

Definition at line 1120 of file CShellLink.cpp.

1121 {
1122  TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1123 
1124  if (cchMaxName)
1125  *pszName = 0;
1126 
1127  if (m_sDescription)
1129  pszName, cchMaxName, NULL, NULL);
1130 
1131  return S_OK;
1132 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetDescription() [2/2]

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

Definition at line 1546 of file CShellLink.cpp.

1547 {
1548  TRACE("(%p)->(%p len=%u)\n", this, pszName, cchMaxName);
1549 
1550  *pszName = 0;
1551  if (m_sDescription)
1552  lstrcpynW(pszName, m_sDescription, cchMaxName);
1553 
1554  return S_OK;
1555 }
#define lstrcpynW
Definition: compat.h:405
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::GetFlags ( DWORD pdwFlags)
virtual

Implements IShellLinkDataList.

Definition at line 2518 of file CShellLink.cpp.

2519 {
2520  TRACE("%p %p\n", this, pdwFlags);
2521  *pdwFlags = m_Header.dwFlags;
2522  return S_OK;
2523 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::GetHotkey ( WORD pwHotkey)
virtual

Implements IShellLinkA.

Definition at line 1216 of file CShellLink.cpp.

1217 {
1218  TRACE("(%p)->(%p)(0x%08x)\n", this, pwHotkey, m_Header.wHotKey);
1219  *pwHotkey = m_Header.wHotKey;
1220  return S_OK;
1221 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetIconLocation() [1/4]

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

Definition at line 1250 of file CShellLink.cpp.

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

Referenced by GetIconLocation().

◆ GetIconLocation() [2/4]

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

Definition at line 1637 of file CShellLink.cpp.

1638 {
1639  TRACE("(%p)->(%p len=%u iicon=%p)\n", this, pszIconPath, cchIconPath, piIcon);
1640 
1641  if (cchIconPath)
1642  *pszIconPath = 0;
1643 
1644  *piIcon = 0;
1645 
1646  /* Update the original icon path location */
1648  {
1650 
1651  /* Search for an icon environment block */
1652  LPEXP_SZ_LINK pInfo;
1654  if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
1655  {
1657 
1660 
1662  if (!m_sIcoPath)
1663  return E_OUTOFMEMORY;
1664 
1666 
1667  m_bDirty = TRUE;
1668  }
1669  }
1670 
1671  *piIcon = m_Header.nIconIndex;
1672 
1673  if (m_sIcoPath)
1674  lstrcpynW(pszIconPath, m_sIcoPath, cchIconPath);
1675 
1676  return S_OK;
1677 }
struct EXP_SZ_LINK * LPEXP_SZ_LINK
#define TRUE
Definition: types.h:120
#define _countof(array)
Definition: fontsub.cpp:30
#define EXP_SZ_ICON_SIG
Definition: shlobj.h:1889
#define lstrcpynW
Definition: compat.h:405
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
DATABLOCK_HEADER *WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature)
Definition: clist.c:424
DWORD WINAPI SHExpandEnvironmentStringsW(LPCWSTR, LPWSTR, DWORD)
#define S_OK
Definition: intsafe.h:59
LPCWSTR szPath
Definition: env.c:35
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ GetIconLocation() [3/4]

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

Definition at line 1275 of file CShellLink.cpp.

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

◆ GetIconLocation() [4/4]

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

Definition at line 1701 of file CShellLink.cpp.

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

◆ GetIDList()

HRESULT STDMETHODCALLTYPE CShellLink::GetIDList ( PIDLIST_ABSOLUTE ppidl)
virtual

Implements IShellLinkA.

Definition at line 1100 of file CShellLink.cpp.

1101 {
1102  TRACE("(%p)->(ppidl=%p)\n", this, ppidl);
1103 
1104  if (!m_pPidl)
1105  {
1106  *ppidl = NULL;
1107  return S_FALSE;
1108  }
1109 
1110  *ppidl = ILClone(m_pPidl);
1111  return S_OK;
1112 }
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228

◆ GetPath() [1/2]

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

Definition at line 1051 of file CShellLink.cpp.

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

◆ GetPath() [2/2]

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

Definition at line 1465 of file CShellLink.cpp.

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

◆ GetShowCmd()

HRESULT STDMETHODCALLTYPE CShellLink::GetShowCmd ( INT piShowCmd)
virtual

Definition at line 1233 of file CShellLink.cpp.

1234 {
1235  TRACE("(%p)->(%p) %d\n", this, piShowCmd, m_Header.nShowCommand);
1236  *piShowCmd = m_Header.nShowCommand;
1237  return S_OK;
1238 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetSite()

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

Definition at line 3096 of file CShellLink.cpp.

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

◆ GetSizeMax()

HRESULT STDMETHODCALLTYPE CShellLink::GetSizeMax ( ULARGE_INTEGER pcbSize)
virtual

Implements IPersistStream.

Definition at line 983 of file CShellLink.cpp.

984 {
985  TRACE("(%p)\n", this);
986  return E_NOTIMPL;
987 }
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ GetWorkingDirectory() [1/2]

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

Definition at line 1152 of file CShellLink.cpp.

1153 {
1154  TRACE("(%p)->(%p len=%u)\n", this, pszDir, cchMaxPath);
1155 
1156  if (cchMaxPath)
1157  *pszDir = 0;
1158 
1159  if (m_sWorkDir)
1161  pszDir, cchMaxPath, NULL, NULL);
1162 
1163  return S_OK;
1164 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_In_ LPCSTR pszDir
Definition: shellapi.h:580
#define S_OK
Definition: intsafe.h:59

◆ GetWorkingDirectory() [2/2]

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

Definition at line 1575 of file CShellLink.cpp.

1576 {
1577  TRACE("(%p)->(%p len %u)\n", this, pszDir, cchMaxPath);
1578 
1579  if (cchMaxPath)
1580  *pszDir = 0;
1581 
1582  if (m_sWorkDir)
1583  lstrcpynW(pszDir, m_sWorkDir, cchMaxPath);
1584 
1585  return S_OK;
1586 }
#define lstrcpynW
Definition: compat.h:405
#define TRACE(s)
Definition: solgame.cpp:4
_In_ LPCSTR pszDir
Definition: shellapi.h:580
#define S_OK
Definition: intsafe.h:59

◆ Initialize()

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

Implements IShellExtInit.

Definition at line 2542 of file CShellLink.cpp.

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

◆ InvokeCommand()

HRESULT STDMETHODCALLTYPE CShellLink::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpici)
virtual

Implements IContextMenu.

Definition at line 2637 of file CShellLink.cpp.

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

◆ IsDirty()

HRESULT STDMETHODCALLTYPE CShellLink::IsDirty ( void  )
virtual

Implements IPersistStream.

Definition at line 318 of file CShellLink.cpp.

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

◆ Load() [1/2]

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

Implements IPersistFile.

Definition at line 324 of file CShellLink.cpp.

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

Referenced by Initialize().

◆ Load() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::Load ( IStream stm)
virtual

Implements IPersistStream.

Definition at line 620 of file CShellLink.cpp.

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

◆ OnCommand()

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

FIXME open target directory

Definition at line 2891 of file CShellLink.cpp.

2892 {
2893  switch (id)
2894  {
2895  case IDC_SHORTCUT_FIND:
2901  return;
2902 
2904  {
2905  WCHAR wszPath[MAX_PATH] = L"";
2906 
2907  if (m_sIcoPath)
2908  wcscpy(wszPath, m_sIcoPath);
2909  else
2910  FindExecutableW(m_sPath, NULL, wszPath);
2911 
2913  if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
2914  {
2915  SetIconLocation(wszPath, IconIndex);
2916  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2917 
2918  HICON hIconLarge = CreateShortcutIcon(wszPath, IconIndex);
2919  if (hIconLarge)
2920  {
2921  if (m_hIcon)
2923  m_hIcon = hIconLarge;
2925  }
2926  }
2927  return;
2928  }
2929 
2930  case IDC_SHORTCUT_ADVANCED:
2931  {
2933  if (result == 1 || result == 0)
2934  {
2935  if (m_bRunAs != result)
2936  {
2937  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2938  }
2939 
2940  m_bRunAs = result;
2941  }
2942  return;
2943  }
2944  }
2945  if (codeNotify == EN_CHANGE)
2946  {
2947  if (!m_bInInit)
2948  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
2949  }
2950 }
#define STM_SETICON
Definition: winuser.h:2074
static HICON
Definition: imagelist.c:84
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDD_SHORTCUT_EXTENDED_PROPERTIES
Definition: shresdef.h:336
#define _countof(array)
Definition: fontsub.cpp:30
#define IDC_SHORTCUT_ICON
Definition: shresdef.h:389
UINT_PTR WPARAM
Definition: windef.h:207
#define IDC_SHORTCUT_CHANGE_ICON
Definition: shresdef.h:406
int32_t INT_PTR
Definition: typedefs.h:62
int32_t INT
Definition: typedefs.h:56
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
BOOL WINAPI PickIconDlg(HWND hWndOwner, LPWSTR lpstrFile, UINT nMaxFile, INT *lpdwIconIndex)
Definition: dialogs.cpp:350
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define MAX_PATH
Definition: compat.h:26
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR IconIndex[]
Definition: install.c:52
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
Definition: shlexec.cpp:1250
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define IDC_SHORTCUT_FIND
Definition: shresdef.h:405
HWND WINAPI GetParent(_In_ HWND)
#define IDC_SHORTCUT_ADVANCED
Definition: shresdef.h:407
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
GLuint64EXT * result
Definition: glext.h:11304
#define EN_CHANGE
Definition: winuser.h:2004

◆ OnDestroy()

void CShellLink::OnDestroy ( HWND  hwndDlg)

Definition at line 3012 of file CShellLink.cpp.

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

◆ OnInitDialog()

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

Definition at line 2819 of file CShellLink.cpp.

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

◆ OnNotify()

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

Definition at line 2952 of file CShellLink.cpp.

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

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 2579 of file CShellLink.cpp.

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

◆ RemoveDataBlock()

HRESULT STDMETHODCALLTYPE CShellLink::RemoveDataBlock ( DWORD  dwSig)
virtual

Implements IShellLinkDataList.

Definition at line 2508 of file CShellLink.cpp.

2509 {
2510  if (SHRemoveDataBlock(&m_pDBList, dwSig))
2511  {
2512  m_bDirty = TRUE;
2513  return S_OK;
2514  }
2515  return S_FALSE;
2516 }
#define TRUE
Definition: types.h:120
#define S_FALSE
Definition: winerror.h:2357
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI SHRemoveDataBlock(LPDBLIST *lppList, DWORD dwSignature)
Definition: clist.c:355

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

◆ ReplacePage()

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

Definition at line 3081 of file CShellLink.cpp.

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

◆ Reset()

VOID CShellLink::Reset ( void  )
private

Definition at line 220 of file CShellLink.cpp.

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

Referenced by Load().

◆ Resolve()

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

Implements IShellLinkA.

Definition at line 1379 of file CShellLink.cpp.

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

Referenced by InvokeCommand().

◆ Save() [1/2]

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

Implements IPersistFile.

Definition at line 345 of file CShellLink.cpp.

346 {
347  TRACE("(%p)->(%s)\n", this, debugstr_w(pszFileName));
348 
349  if (!pszFileName)
350  return E_FAIL;
351 
352  CComPtr<IStream> stm;
354  if (SUCCEEDED(hr))
355  {
356  hr = Save(stm, FALSE);
357 
358  if (SUCCEEDED(hr))
359  {
360  if (m_sLinkPath)
362 
364  m_bDirty = FALSE;
365  }
366  else
367  {
369  WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName));
370  }
371  }
372 
373  return hr;
374 }
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define WARN(fmt,...)
Definition: debug.h:111
#define STGM_CREATE
Definition: objbase.h:925
#define E_FAIL
Definition: ddrawi.h:102
#define debugstr_w
Definition: kernel32.h:32
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
LONG HRESULT
Definition: typedefs.h:77
#define STGM_READWRITE
Definition: objbase.h:918
HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
Definition: istream.c:484
#define HeapFree(x, y, z)
Definition: compat.h:402
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by OnNotify().

◆ Save() [2/2]

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

Implements IPersistStream.

Definition at line 859 of file CShellLink.cpp.

860 {
861  TRACE("%p %p %x\n", this, stm, fClearDirty);
862 
863  m_Header.dwSize = sizeof(m_Header);
864  m_Header.clsid = CLSID_ShellLink;
865 
866  /*
867  * Reset the flags: keep only the flags related to data blocks as they were
868  * already set in accordance by the different mutator member functions.
869  * The other flags will be determined now by the presence or absence of data.
870  */
873 #if (NTDDI_VERSION < NTDDI_LONGHORN)
875 #endif
877  // TODO: When we will support Vista+ functionality, add other flags to this list.
878 
879  /* The stored strings are in UNICODE */
881 
882  if (m_pPidl)
884  if (m_sPath)
888  if (m_sPathRel && *m_sPathRel)
890  if (m_sWorkDir && *m_sWorkDir)
892  if (m_sArgs && *m_sArgs)
894  if (m_sIcoPath && *m_sIcoPath)
896  if (m_bRunAs)
898 
899  /* Write the shortcut header */
900  ULONG count;
901  HRESULT hr = stm->Write(&m_Header, sizeof(m_Header), &count);
902  if (FAILED(hr))
903  {
904  ERR("Write failed\n");
905  return hr;
906  }
907 
908  /* Save the data in order */
909 
910  if (m_pPidl)
911  {
912  hr = ILSaveToStream(stm, m_pPidl);
913  if (FAILED(hr))
914  {
915  ERR("Failed to write PIDL\n");
916  return hr;
917  }
918  }
919 
920  if (m_sPath)
921  {
923  if (FAILED(hr))
924  return hr;
925  }
926 
928  {
930  if (FAILED(hr))
931  return hr;
932  }
933 
935  {
937  if (FAILED(hr))
938  return hr;
939  }
940 
942  {
944  if (FAILED(hr))
945  return hr;
946  }
947 
949  {
950  hr = Stream_WriteString(stm, m_sArgs);
951  if (FAILED(hr))
952  return hr;
953  }
954 
956  {
958  if (FAILED(hr))
959  return hr;
960  }
961 
962  /*
963  * Now save the data block list.
964  *
965  * NOTE that both advertised Product and Component are already saved
966  * inside Logo3 and Darwin data blocks in the m_pDBList list, and the
967  * m_Header.dwFlags is suitably initialized.
968  */
970  if (FAILED(hr))
971  return hr;
972 
973  /* Clear the dirty bit if requested */
974  if (fClearDirty)
975  m_bDirty = FALSE;
976 
977  return hr;
978 }
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei count
Definition: gl.h:1545
HRESULT WINAPI ILSaveToStream(IStream *pStream, LPCITEMIDLIST pPidl)
Definition: pidl.c:342
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI SHWriteDataBlockList(IStream *lpStream, LPDBLIST lpList)
Definition: clist.c:179
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int ULONG
Definition: retypes.h:1
HRESULT Write([in, size_is(cb)] const void *pv, [in] ULONG cb, [out] ULONG *pcbWritten)

◆ SaveCompleted()

HRESULT STDMETHODCALLTYPE CShellLink::SaveCompleted ( LPCOLESTR  pszFileName)
virtual

Implements IPersistFile.

Definition at line 376 of file CShellLink.cpp.

377 {
378  FIXME("(%p)->(%s)\n", this, debugstr_w(pszFileName));
379  return S_OK;
380 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
#define S_OK
Definition: intsafe.h:59

◆ SetAdvertiseInfo()

HRESULT CShellLink::SetAdvertiseInfo ( LPCWSTR  str)
private

Definition at line 2086 of file CShellLink.cpp.

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

Referenced by SetPath().

◆ SetArguments() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCSTR  pszArgs)
virtual

Implements IShellLinkA.

Definition at line 1198 of file CShellLink.cpp.

1199 {
1200  TRACE("(%p)->(args=%s)\n", this, pszArgs);
1201 
1203  m_sArgs = NULL;
1204 
1205  if (pszArgs)
1206  {
1207  m_sArgs = HEAP_strdupAtoW(GetProcessHeap(), 0, pszArgs);
1208  if (!m_sArgs)
1209  return E_OUTOFMEMORY;
1210  }
1211  m_bDirty = TRUE;
1212 
1213  return S_OK;
1214 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by OnNotify().

◆ SetArguments() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetArguments ( LPCWSTR  pszArgs)
virtual

Implements IShellLinkW.

Definition at line 1619 of file CShellLink.cpp.

1620 {
1621  TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs));
1622 
1624  m_sArgs = NULL;
1625 
1626  if (pszArgs)
1627  {
1628  m_sArgs = strdupW(pszArgs);
1629  if (!m_sArgs)
1630  return E_OUTOFMEMORY;
1631  }
1632  m_bDirty = TRUE;
1633 
1634  return S_OK;
1635 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ SetDescription() [1/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCSTR  pszName)
virtual

Implements IShellLinkA.

Definition at line 1134 of file CShellLink.cpp.

1135 {
1136  TRACE("(%p)->(pName=%s)\n", this, pszName);
1137 
1139  m_sDescription = NULL;
1140 
1141  if (pszName)
1142  {
1144  if (!m_sDescription)
1145  return E_OUTOFMEMORY;
1146  }
1147  m_bDirty = TRUE;
1148 
1149  return S_OK;
1150 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ SetDescription() [2/2]

HRESULT STDMETHODCALLTYPE CShellLink::SetDescription ( LPCWSTR  pszName)
virtual

Implements IShellLinkW.

Definition at line 1557 of file CShellLink.cpp.

1558 {
1559  TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
1560 
1562  m_sDescription = NULL;
1563 
1564  if (pszName)
1565  {
1566  m_sDescription = strdupW(pszName);
1567  if (!m_sDescription)
1568  return E_OUTOFMEMORY;
1569  }
1570  m_bDirty = TRUE;
1571 
1572  return S_OK;
1573 }
#define TRUE
Definition: types.h:120
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define S_OK
Definition: intsafe.h:59
#define HeapFree(x, y, z)
Definition: compat.h:402

◆ SetFlags()

HRESULT STDMETHODCALLTYPE CShellLink::SetFlags ( DWORD  dwFlags)
virtual

Implements IShellLinkDataList.

Definition at line 2525 of file CShellLink.cpp.

2526 {
2527 #if 0 // FIXME!
2529  m_bDirty = TRUE;
2530  return S_OK;
2531 #else
2532  FIXME("\n");
2533  return E_NOTIMPL;
2534 #endif
2535 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ SetHotkey()

HRESULT STDMETHODCALLTYPE CShellLink::SetHotkey ( WORD  wHotkey)
virtual

Implements IShellLinkA.

Definition at line 1223 of file CShellLink.cpp.

1224 {
1225  TRACE("(%p)->(hotkey=%x)\n", this, wHotkey);
1226 
1227  m_Header.wHotKey = wHotkey;
1228  m_bDirty = TRUE;
1229 
1230  return S_OK;
1231 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ SetIconLocation() [1/2]

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

Definition at line 1320 of file CShellLink.cpp.

1321 {
1322  TRACE("(%p)->(path=%s iicon=%u)\n", this, pszIconPath, iIcon);
1323 
1324  LPWSTR str = NULL;
1325  if (pszIconPath)
1326  {
1327  str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
1328  if (!str)
1329  return E_OUTOFMEMORY;
1330  }
1331 
1332  HRESULT hr = SetIconLocation(str, iIcon);
1333 
1334  if (str)
1335  HeapFree(GetProcessHeap(), 0, str);
1336 
1337  return hr;
1338 }
HRESULT hr
Definition: shlfolder.c:183
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
LONG HRESULT
Definition: typedefs.h:77
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by OnCommand().

◆ SetIconLocation() [2/2]

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

Definition at line 1857 of file CShellLink.cpp.

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