Calling Win32 APIs from WPF applications
Windows Presentation Foundation and Win32 interpolation can work as different approaches. You can either host a Win32 application in a WPF application, a WPF application in a Win32 application, or call a Win32 API from WPF by importing the specified system DLL. These are often useful when you have already invested a lot in Win32 applications and now you would like to build a rich WPF application by utilizing the existing code.
In this recipe, we will learn how to call a Win32 API from a WPF. We will use a simple example to launch a browser window and then activate/refresh the browser window from our WPF code.
Getting ready
Get started by creating a WPF application. Open your Visual Studio IDE, and create a new project named CH11.Win32ApiCallDemo
. Make sure to select WPF App (.NET Framework)
as the project template.
How to do it...
Follow these steps to give a call to Win32 APIs from WPF applications:
- First, we need to set up the project. Once the project...