These 2 classes encapsulate the IShellLink & IUniformResourceLocator COM
interfaces as provided in Win32. These 2 interfaces allow you to programmatically
create the ubiquitous shortcuts (*.lnk files) as well as Url shortcuts (*.url files).
The classes provides a simple C++ wrapper over the SDK API. The classes also
provides auto cleanup and is UNICODE enabled with build configurations provided.
The enclosed zip file contains the CLink/CUrlLink
source code and also includes a VC 2017 solution to build a small demonstration
app.
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
Updates
v1.24 (20 May 2023)
- Updated copyright details
- Updated modules to indicate that it needs to be compiled using
/std:c++17. Thanks to Martin Richter for reporting this issue.
v1.23 (23 March 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations
- Updated the code to use std::[w]string::data method throughout. This
means that the code must now be compiled using /std:c++17.
v1.22 (22 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.21 (17 November 2019)
- Updated initialization of various structs to use C++ 11 list
initialization
v1.20 (2 June 2019)
- Updated copyright details.
- Updated the code to clean compile on VC 2019
v1.19 (1 September 2018)
- Fixed a number of compiler warnings when using VS 2017 15.8.1
v1.18 (11 August 2018)
- Updated copyright details
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Removed code which supported the CSHELLLINK_MFC_EXTENSIONS preprocessor
define
- Replaced BOOL throughout the codebase with bool
- Replaced NULL throughout the codebase with nullptr
- Replaced ATL::CHeapPtr<BYTE> throughout the codebase with
std::vector<BYTE>
- Added support for PKEY_AppUserModel_IsDestListSeparator property
- Added support for PKEY_AppUserModel_RelaunchCommand property
- Added support for PKEY_AppUserModel_RelaunchDisplayNameResource property
- Added support for PKEY_AppUserModel_RelaunchIconResource property
1 May 2017
- Updated the demo app to compile cleanly using /permissive-.
v1.17 (7 January 2016)
- Updated copyright details.
- Updated CDataList::FillConsolePropsFromRegistry to use ERROR_SUCCESS define.
- Updated the code to clean compile on VC 2015
v1.16 (21 June 2015)
- Updated copyright details.
- Updated the code to require VC 2008 or later. This means that the code can
drop the requirement to use __if_exists to conditionally compile out certain
functionality
- Added SAL annotations to all the code
- All the classes have now been put in a "ShellLinks" namespace
- Reworked the classes to optionally compile without MFC. By default the classes
now use STL classes and idioms but if you define CSHELLLINK_MFC_EXTENSIONS the
classes will revert back to the MFC behaviour.
- Renamed the CPropertyStoreForShellLink class to CPropertyStore.
- Renamed the CShellLinkDataList class to CDataList
- Renamed the CShellLinkHelper class to CHelper
- Renamed the CShellLink class to CLink
- Renamed the CUrlShellLink class to CUrlLink
- Added SetStartPinOption, GetStartPinOption, GetDualMode & SetDualMode
methods to the CPropertyStore class
- Update the CPropertyStore::GetBooleanProperty to use PropVariantToBoolean
- Updated CPropertyStore::GetStringProperty to handle VT_BSTR values in addition
to VT_LPWSTR
- All the methods in CHelper have been made non-const
- CUrlLink::Invoke now takes a HWND parameter
- Remove the CShellLink::Resolve method as it did not provide any real useful
C++ encapsulation.
v1.14 (21 May 2011)
- Updated copyright details.
- Updated code to compile cleanly using VC 2005 and later
- The code has now been updated to support VC 2005 or later only.
- Moved all the code inline into shelllink.h and did a major refactoring of
the code to provide a cleaner wrapping for the IShellLink and IUniformResourceLocator
interfaces.
- Added comprehensive support for IShellLinkDataList and all its supported
structures including EXP_DARWIN_LINK, EXP_SPECIAL_FOLDER, EXP_SZ_LINK, NT_CONSOLE_PROPS,
NT_FE_CONSOLE_PROPS and EXP_PROPERTYSTORAGE
v1.15 (21 May 2011)
- Major refactor of the code into new helper classes of CPropertyStoreForShellLink,
CShellLinkDataList & CShellLinkHelper. The two main classes of CShellLink
and CUrlShellLink now provide various Get methods to pull out these helper classes
- Updated the classes to support the following Windows 7 properties: PKEY_AppUserModel_ExcludeFromShowInNewInstall,
PKEY_AppUserModel_PreventPinning & PKEY_AppUserModel_ID
v1.13 (20 December 2006)
- Updated copyright details.
- Addition of a SHELLLINK_EXT_CLASS preprocessor macro to allow the class
to be more easily added to an extension DLL.
- Optimized CShellLinkInfo constructor
- Optimized CShellLink constructor
- Code now uses newer C++ style casts instead of C style casts.
- Optimized CUrlShellLink constructor
- Updated the sample app to clean compile on VC 2005
- CShellLinkInfo is no longer derived from CObject as it was not really required
- Classes now use ATL's CComPtr for managing the various COM pointers
- Return values from functions now use HRESULT's instead of plain BOOL's
- The way the classes are now initialized have been reworked based on the
way the "FinalConstruct" mechanism works in ATL
- CUrlShellLink class is now no longer derived from CShellLink class
- Fixed a potential COM reference count bug in CShellLinkInfo::operator= where
we were making naked copies of a PIDL. Now the code makes a copy of the PIDL
so that each CShellLinkInfo class instance maintains its own separate copy of
its PIDL.
- Updated the documentation to use the same style as the web site.
v1.12 (26 January 2003)
- Fixed up #include of system headers so that they can be included in the
PCH
- Moved initialization of the GUIDs from the code to the sample app.
- Fixed a copy and paste bug in the CShellLink::GetArguments() method. Thanks
to "Bin" for reporting this problem.
v1.11 (4 April 2001)
- Updated copyright information
- Fixed 2 bugs in CURLLink::Save and CURLLink::Load. Thanks to Martin MacRobert
for spotting the problems
- Fixed COM interface leaks in CUrlShellLink::~CUrlShellLink
v1.1 (12 December 1998)
- Updated sample program to be called ShelLink.
- Fixed a bug in CUrlShellLink::Save where m_sTarget was not being set.
- Updated the trace comments in the code to include the function from which
the function fails.
- Demo program now displays some info about what it is doing to the console
window.
- Default build configuration is now ASCII Debug instead of Unicode Debug.
v1.0 (10 December 1998)