Working with low level code is becoming less necessary as Microsoft continues to improve the .NET Framework, but you sometimes still need to resort to direct Win32 API access using P/Invoke. My book, “.NET Framework Solutions: In Search of the Lost Win32 API,” is a great place to learn about P/Invoke and the significant number of ways you can use it to access Windows features that Microsoft hasn’t made available in the .NET Framework yet. For example, you’ll find a thorough discussion of the Windows messaging system in Chapter 4. However, the discussion is a bit lengthy because there is so much you can do with the Windows messaging system.
One of the questions I get asked quite often is whether there is a quick start sort of guide I can recommend for working with the Windows messaging system. With that in mind, I wrote a series of four DevSource articles some time ago. Here’s the complete article list:
- Working with Windows Messages in .NET
- Hooking Windows Messages in .NET
- Globally Hooking Windows Messages in .NET
- Special Windows Message Hooking Techniques for .NET
These four articles provide quite a bit of information about Windows messages that you might not know from a .NET perspective. Using these techniques can save you considerable time, especially when you need to interact with other applications. In fact, the final article reveals secrets you can use to interact with applications when you don’t have the source code; a significant problem for most developers. So, how do you use P/Invoke? Have you had to resort to P/Invoke to work with Windows 7 features that haven’t been added to the .NET Framework yet? Let me know at John@JohnMuellerBooks.com.