Tip: Turning Win32 Console app to non-Console app

Monday, September 30, 2013

Let’s say you’ve created a Win32 Console Application in Visual Studio:We get the classic main function.Now suppose that after working on the project for a while we want to turn the app into a Windows app – no console. At first, this seems easy: just replace the main function with a proper WinMain: int _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int nCmdShow) Unfortunately, that’s not enough. Building the project produces the following linker error:MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartupThe linker still expects a main function.The solution is (apart...
no comments

Getting rid of the Start button – Adding a Hook

Monday, September 16, 2013

In the previous post we saw how to find and remove the start button and move the task bar window to the left to occupy the free space left by the former start button.However, we saw that by opening the system tray, the task bar moves back to its original position. We need to know when that happens, and then use the same trick to move it back to the “right” position.To do that we would need to register somehow for the WM_MOVE message. This is one option, and we can verify this using Spy++’s Message window for task...

Getting rid of the Start button in Windows 8.1

Sunday, September 15, 2013

Windows 8.1 brings back the famous Start button, but alas – it’s not the good Start button from Windows 7. It’s just yet another way to get to the new Home screen. This makes the Start button (at least for me) completely useless, as there are already several ways to get to the Home screen (Windows key on the keyboard, mouse moved to the bottom left corner, touch devices can press the hardware Start button, the Charms bar has a Start button…).There are utilities that can simulate the old Windows 7 Start button, if I don’t have such a...

Interpreting a Handle’s Access Mask

Monday, August 19, 2013

When opening a handle to a kernel object with some Open* Windows API function (e.g. OpenProcess, OpenThread, OpenEvent, …) an access mask must be specified, indicating the type of access requested from the resulting handle. Requiring too much access may cause the call to fail, so a best practice is to require the only access flags that are needed to get the job done.For example, suppose we want to know when a running process terminates. This requires obtaining a handle to the process in question and calling WaitForSingleObject on that handle. For this, only the SYNCHRONIZE access is required: HANDLE...

My first PluralSight course has been published!

Thursday, August 8, 2013

In the last few months, I’ve been working on a course for PluralSight. Creating a video course is not easy, as I found out first hand. In fact, it’s more difficult than writing a book. With a book, I can change a sentence or a paragraph, at any time and any place. A video course is different… changes are hard, and recording sessions cannot be done just anywhere. But I’ve learned a lot from the experience, which should make next courses a bit easier…My first course is about a favorite subject of mine, Windows Internals. This deals with the...

My Wish List for Windows “Blue”

Friday, May 17, 2013

Many rumors are flying around at this time about the upcoming release of Windows 8.1 (code named “Blue”, which represents a wave of product updates, including Windows Phone and others). I thought I‘d state my hopes for this release, not just in terms of user features, but also from a developer’s perspective. As a developer, I spend most of my time on my trusty laptop, not some tablet based device. Naturally, the desktop world is my friend. The Windows 8 Start screen is close to perfect for tablet devices, but for the desktop – it’s practically useless. With many...

My New Book Project

Tuesday, March 5, 2013

Those of you who follow my blog may have noticed a slowdown in posts. The main reason for this is that I am working on a new book, titled “Windows 8 C++ App Development” to published by Packt Publishing in about 2 months time.The book has now an official URL in Pack’s web site (no Amazon link yet, but soon…).The book is aimed towards C++ developers that want to use the power and flexibility of C++ to write Windows 8 Store Apps, while leveraging XAML as the UI technology. It includes a good coverage of C++/CX and most features...

Windows Media Foundation in Windows 8

Tuesday, November 20, 2012

Windows Media Foundation was introduced in Windows Vista as a future replacement for DirectShow, enhanced in Windows 7, and naturally, further enhanced in Windows 8. I’ve blogged about WMF before. While looking at the MSDN docs on WMF, it seems the content has not yet been updated for Windows 8. Windows 7 enhancements are considered there as such. Looking at the API reference, however, shows some new interfaces that are only supported starting with Windows 8.One such interface is IMFMediaEngine and its extended version, IMFMediaEngineEx. The docs hint that the former interface is the playback interface used by the...

Using C++/CX in Desktop apps

Saturday, September 29, 2012

In my first and second post on using WinRT in a desktop app, we’ve used the raw API and then WRL to create and access WinRT objects. It would be easier to access WinRT using the new C++/CX extensions. Can we do that from a desktop app? Let’s give it a try.We’ll start with a regular Win32 Console application project. The first thing we need to do is to enable the C++/CX extensions. Open project properties and navigate to the C/C++ / General node and set “Consume Windows Runtime Extension” to Yes:Building the project now causes the compiler to...

Accessing WinRT from Desktop Apps (Part 2)

Monday, September 24, 2012

In the previous post we’ve seen how to instantiate WinRT objects using the raw (Ro, pun intended) API. In this post, we’ll see some shortcuts to make our lives a little easier.These shortcuts are part of the Windows Runtime template Library (WRL). This is a helper library, similar in spirit to the Active Template Library (ATL) used for classic COM work.First we need to include the main WRL header, <wrl.h>. Also, we’ll include another header with some extra helpers, that are not included with the primary header:#include <wrl.h> #include <wrl/wrappers/corewrappers.h> Next, we’ll add using namespace statements to make our lives a...
no comments