ShellLinks::CLink & CShellLinks::CUrlLink v1.24
Welcome to CLink & CUrlLink, 2 freeware C++ wrapper
classes to encapsulate shell shortcuts.
Features
- Simple and clean C++ interface.
- All code compiles cleanly at
level 4, is UNICODE enabled, SAL & /permissive- clean.
- A simple console app is provided which tests the various class methods
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.
Usage
- To use the class in your code simple #include ShellLink.h in which ever of your modules needs to make calls to
the classes.
- To see the classes in action, have a look at the code in main() in the module
"main.cpp".
- CLink implements the main IShellLink interface for standard
shortcuts (*.lnk files) and all the methods of IShellLink are available
using the standard CComPtr::operator->() method. Where it makes sense
various helper methods have been added to CLink to hide string buffer
manangement e.g CShellLink::GetPath proves an overide of IShellLink::GetPath
which works directly with a std::[w]string reference. The CLink class also
exposes the methods of IPersistFile::Save, IPersistFile::Load,
CoCreateInstance (as CShellLink::Initialize) as well as all the methods
of IShellLinkDataList.
- A CLink::FillConsolePropsFromRegistry method is provided which allows a
NT_CONSOLE_PROPS structure to be filled with the default console settings
from HKEY_CURRENT_USER\Console.
- CUrlLink implements the IUniformResourceLocator interface which is
used for URL shortcuts (*.url files) and all the methods of
IUniformResourceLocator are available
using the standard CComPtr::operator->() method. Where it makes sense various helper
methods have been added to CUrlLink to hide string buffer manangement
e.g CUrlShellLink::GetURL proves an overide of IUniformResourceLocator::GetURL
which works directly with a std:[w]string reference. The CUrlLink class also
exposes the methods of IPersistFile::Save, IPersistFile::Load,
CoCreateInstance (as CUrlShellLink::Initialize) as well as all the methods
of IShellLink.
- As of v1.18, the code is now for Visual C++ 2017 or later only.
History
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
30 April 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.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.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.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)
Contacting the Author
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
20 May 2023