Posts

Using a subset of the boost libraries in Windows

Image
For many C++ applications I very much want to use the Boost libraries, just not the whole set. This post explains how to use the bcp tool to create a subset of the Boost libraries in order to leave out unnecessary libraries and tailor it to the needs of your project. One nice thing about bcp is that it can be run at any time so as to update your Boost dependencies as and when the need arises.

Converting a SYSTEMTIME to a std::string in C++

Image
A short recipe outlining how to output a SYSTEMTIME value as a std::string. The example format will be "YYYY-MM-DD HH:MM:SS.MMM" I specifically wanted to include milliseconds. In this example I employ three possible techniques: 1. MFC CString 2. std::ostringstream 3. sprintf

Using boost::filesystem

Image
Examples of using boost::filesystem for various things as and when I encounter them... Many have been lifted from the StackOverflow site. For reasons of brevity and clarity I generally avoid extraneous code such as exception handling etc in these examples and just focus on the techniques themselves. Shortcuts to examples covered in this boost file system tutorial are as follows: 1. Copying a directory 2. Iterating over files in a directory 3. Recursively search for a file within a directory and its subdirectories 4. Counting the number of files in a directory 5. Find out when a file was last modified 6. Rename a file 7. To remove a file or directory 8. To create a directory 9. Obtaining relative paths 10. Recursively find/delete all files in a directory 1. Copying a directory This recursively uses boost::filesystem::create_directory to create a copy of a directory including its contents, sub-directories etc. For example the MyStuff folder: Use the followi...

Getting Started with TinyXml

Image
Step 1: Download and install TinyXML Download and extract the library from http://www.grinninglizard.com/tinyxml/ TinyXML source files as shown:

An editable MFC List Control

Image
A run-through on how to create a editable MFC List Control by making the CListCtrl editable. Visual Studio 2010 project downloadable from here . Much of the credit for this must go to Zafir Anjum on the Codeguru site for an article called "Editable subitems" from which this post borrows quite heavily.

Installing and using OpenSSL SHA-256 in Visual C++

Image
Background SHA-256 is a cryptographic hash function developed by the US. National Security Agency (NSA) as a U.S. Federal Information Processing Standard (FIPS). The SHA acronym stands for Secure Hash Algorithm. A hash function operates on an arbitrary amount of data and returns a fixed-size bit string, the cryptographic hash value. So why would such an algorithm be useful? Its utility lies in the fact that attempts to change the original data will almost certainly change the hash value returned by the algorithm. An obvious application would be to apply such an algorithm to a file (text or binary) as a means of determining whether or not it has been tampered with. This post shows you how to use SHA-256 as implemented by the OpenSSL open source project, and use it within Windows / Visual C++ environments to produce digital signatures of strings or files.

Reading the status of DVD drives in C++

Image
A short and to-the-point C++ recipe for determining the status of your PC / laptop DVD. To study this area in more depth, follow this link for more information, which is where I got much of this inspiration for this code snippet. It works. http://ws0.org/windows-how-to-get-the-tray-status-of-the-optical-drive/ Full code listing