10 Practical Techniques to Power Your Visual C++ Apps

Explore practical solutions to ten common problems that can be solved quite effectively with Visual C++.
Course info
Rating
(57)
Level
Intermediate
Updated
Dec 10, 2013
Duration
7h 14m
Table of contents
Searching and Sorting Text
Downloading Files with Internet Explorer
Reading and Writing XML
Using WebSockets
Using Databases on Windows Azure
Using SQLite Databases
Working with File Paths
Creating Layered Windows
Writing High-DPI Applications
Applying Cryptography
Description
Course info
Rating
(57)
Level
Intermediate
Updated
Dec 10, 2013
Duration
7h 14m
Description

Visual C++ has a bad reputation for productivity when compared with its .NET counterparts in the Visual Studio family. While I won’t argue with the fact that simple tasks can often be a little more complicated in C++, the benefits are often worthwhile. From faster and more responsive apps to dramatically reduced memory usage and more predictable resource management. These are all critical factors when producing apps for a new generation of increasingly mobile devices. In this course you’re going to discover many techniques to search, sort and generate text and XML. You’ll discover effective ways to access the web, communicate with web sockets, and access databases on Windows Azure. You’re going to learn how to master long file paths, layered windows, and how to use SQLite. You’ll discover that writing high-DPI application’s needn’t be hard and how to apply cryptography to keep the bad guys out. There’s something here for everyone!

About the author
About the author

Kenny Kerr is a computer programmer and recognized expert in Windows operating system development and programming languages.

More from the author
Windows Runtime Internals
Advanced
2h 41m
Jul 30, 2015
SQLite with Modern C++
Intermediate
2h 33m
Feb 18, 2015
The Essentials of the Windows Runtime
Intermediate
2h 48m
Sep 2, 2014
More courses by Kenny Kerr
Section Introduction Transcripts
Section Introduction Transcripts

Searching and Sorting Text
Welcome to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr and in this Pluralsight course we're going to explore 10 common problems covering a broad spectrum from computer science and see how they might be solved using Visual C++. Visual C++ has a bad reputation for productivity when compared with its. NET counterparts in the Visual Studio family. While I won't argue with the fact that simple tasks can often be a little more complicated in C++, the benefits are often worthwhile. From faster and more responsive apps, to dramatically reduced memory usage, and more predictable resource management. These are all critical factors when producing apps for a new generation of increasingly mobile devices. In the first module we're going to explore the topic of searching and sorting text. This is a common problem for many applications, but C++ is often favored for its good performance and reduced working set. There are of course many ways that searching and sorting may be achieved. I'm going to show you just a few to get you started, but we'll also favor techniques that can provide optimal performance and efficiency by leveraging the libraries available with Visual C++ and the Windows Operating System. As always, I'll be using the latest version of Visual C++, Visual C++ 2013 in this case, and I encourage you to follow along on your own PC.

Downloading Files with Internet Explorer
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr, and in this module we're going to explore different ways to download content from the web. There are actually a surprising number of ways that you can do this with Visual C++, but I'll focus here on some of the simpler approaches provided by Internet Explorer itself. Whether you like using Internet Explorer to browse the web or not, you'll undoubtedly enjoy the convenience and sheer power at your fingertips that this browser offers up directly to C++ programmers. Specifically, it offers three closely related functions in particular that I'm going to illustrate in this module. There may be some reasons not to use Internet Explorer's download functionality, perhaps you need to download many files and want to do so asynchronously, but it's hard to beat the relative simplicity and power at your fingertips provided by these functions, so let's begin.

Reading and Writing XML
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr, and in this module we're going to explore the use of XML with C++. The popularity of XML grew with the introduction of managed and dynamic languages, but there's no reason you should shy away from XML just because you happen to prefer Visual C++. Windows has long supported a very fast and lightweight XML parser called XmlLite. Just to set some expectations, XmlLite does not provide a document object model or DOM, nor does it provide support for XML Schema, document type definition or DDD validation. It doesn't support cursor-based navigation like XPath, style sheets or serialization. So what good is it? Well, you should know by now that I am interested in performance, and XmlLite does not disappoint. It provides a non-cached, forward-only parser. It's a very lightweight, but very fast XML reader and writer. Since it's not trying to do everything or be everything to everyone, it tends to be a good building block when you need a bit of solid XML parsing or generation, but don't want to invest in a bigger library or framework. In this module we'll consider a simple example. Let's download some XML. I'll use my blog's RSS feed. We'll then parse it looking for blog posts and extract the titles and links. Then, we'll generate an HTML document, again using XmlLite to display the links. This should give us a good tour of XmlLite and its capabilities. It's time to write some code.

Using WebSockets
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr and in this module I'm going to show you how to connect to a web server and establish a WebSocket connection. The main goal of the WebSocket protocol is to enable a standard and efficient method by which applications and web servers can communicate outside of request response pairs. It should be assumed that the client will always be doing the requesting. What if a server wants to push data to the client? WebSockets make this possible in a surprisingly efficient way by upgrading an HTTP connection to a WebSocket connection, thereby re-using the underlying TCP connection to produce a bidirectional communications channel between the two parties. WebSockets in IO or network communication is a potentially vast topic. I have already written about WebSockets in detail for MSDN Magazine. I've also got a lot of requests for a course in IO and network communication, which I hope to provide soon, but in this module I'm just going to give you a whirlwind tour of what's involved in setting up a WebSocket client in C++.

Using Databases on Windows Azure
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr, and in this module we're going to explore the use of SQL databases on Windows Azure. The good news is that this is just the same SQL Server product that we've come to know. It just happens to be hosted in the Cloud with an incredibly simple front-end management experience in the browser. The bad news is that SQL Server doesn't have a particularly good API for native code. It's not bad, but it can be a little awkward at times to program SQL Server with ODBC. That's right. ODBC is back. ODBC is one of the oldest database access technologies still in common use, and yet it's the only long-term solution for C++ programmers. If you've programmed SQL Server with C++ before, you may be familiar with OLE DB, a COM-based API for data access, which was rather revolutionary in its day. Unfortunately, that has been abandoned and Microsoft has standardized on the older, but simpler ODBC C-style API for C++ developers. Let's take a look.

Using SQLite Databases
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr and in this module we're going to take a look at the SQLite Database Engine. The beauty of SQLite is that it's a software library in the best sense of the word library. It ships in a single source file. Okay, there's also a header file, but it's close. So as it advertises on the SQLite website, it's a self-contained server list, zero configuration or installation, transactional SQL database engine. It's very simple to use, especially from C or C++, since it's written entirely in C and can easily be incorporated into your visual C++ project. It has been widely used for small and large programs alike and has had a big impact on mobile apps and games due to its portability and small footprint. Still, as I mentioned, it's written entirely in C, so like the ODBC API we looked at in the previous module, it takes a bit of love from C++ to get it to work smoothly and elegantly in C++. Let's take a look.

Working with File Paths
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr, and in this module we're going to look at how to handle File Paths. This might seem obvious or trivial, but there are in fact many pitfalls and challenges when working with paths for files and folders. How are paths built or combined, is a path valid or canonical? What about long file names? All these and more are the subject of this module. Without considering how to work with file paths, your apps are likely to break or fail in the most mysterious ways, and likely only when your customers are using it for the first time, far, far away from your test lab. This is in the realm of software taxes, stuff you need to pay attention to, but that customers just take for granted. They may take it for granted, but they'll hate you for getting it wrong. So let's get started.

Creating Layered Windows
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr, and in this module we're going to look at Creating Layered Windows. Layered windows provide the unique capability of rendering a window where portions of the windows bounding rectangle are in fact transparent, or at least not fully opaque. This all comes down to a bitmap with an alpha channel that the application may produce to define which parts of the window will be visible, and which will be transparent. Naturally, there are different ways of achieving this, with various trade-offs. So let's take a look.

Writing High-DPI Applications
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr, and in this module, we're going to look at creating High DPI or DPI-aware applications that make the best of Windows 8. 1. While I covered DPI-aware applications in my Direct2D courses, Windows 8. 1 changed the game substantially by allowing DPI Settings to change on the fly without requiring the user to sign out and force all applications to Restart. I'll be focusing on applications rendered with DirectX. While incorrectly handling DPI settings in a DirectX application is less noticeable, it's still important to get it right, so that your application provides the best user experience. Windows 8. 1 just takes this even further. Not only can the DPI value change on the fly, but it can be different from one monitor to the next. That way, if you have a large 30-inch monitor plugged into your tablet, both screens don't have to share the same scaling factor. In this module, I'm going to show you what it takes to make your visual C++ apps ready to handle DPI changes, so that they'll work well with Windows 7 and Windows 8, as well as Windows 8. 1.

Applying Cryptography
Welcome back to 10 Practical Techniques to Power Your Visual C++ Apps. My name is Kenny Kerr and in this module I'm going to show you how to quickly get going with various cryptographic algorithms provided by the Windows operating system. Windows Vista introduced a new cryptography API providing a simpler and more consistent API surface for performing various cryptographic operations from generating random numbers, working with hash functions, signatures and verification, and of course symmetric and asymmetric encryption. This API, known as CNG, which stands for cryptography next generation continues to be the most efficient and reliable set of cryptographic primitives available to Windows developers. Let's take a look.